mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-20 20:25:48 +00:00
Add escrow support
This commit is contained in:
@@ -30,10 +30,11 @@
|
|||||||
"AccountRoot": 97,
|
"AccountRoot": 97,
|
||||||
"RippleState": 114,
|
"RippleState": 114,
|
||||||
"FeeSettings": 115,
|
"FeeSettings": 115,
|
||||||
"SuspendedPayment": 117,
|
"Escrow": 117,
|
||||||
"DirectoryNode": 100,
|
"DirectoryNode": 100,
|
||||||
"GeneratorMap": 103,
|
"GeneratorMap": 103,
|
||||||
"Contract": 99,
|
"Contract": 99,
|
||||||
|
"PayChannel": 120,
|
||||||
"Invalid": -1
|
"Invalid": -1
|
||||||
},
|
},
|
||||||
"FIELDS": [
|
"FIELDS": [
|
||||||
@@ -988,7 +989,17 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
"Proof",
|
"Fulfillment",
|
||||||
|
{
|
||||||
|
"nth": 16,
|
||||||
|
"isVLEncoded": true,
|
||||||
|
"isSerialized": true,
|
||||||
|
"isSigningField": true,
|
||||||
|
"type": "Blob"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"Condition",
|
||||||
{
|
{
|
||||||
"nth": 17,
|
"nth": 17,
|
||||||
"isVLEncoded": true,
|
"isVLEncoded": true,
|
||||||
@@ -1556,9 +1567,9 @@
|
|||||||
"OfferCreate": 7,
|
"OfferCreate": 7,
|
||||||
"SignerListSet": 12,
|
"SignerListSet": 12,
|
||||||
"Contract": 9,
|
"Contract": 9,
|
||||||
"SuspendedPaymentCreate": 1,
|
"EscrowCreate": 1,
|
||||||
"SuspendedPaymentFinish": 2,
|
"EscrowFinish": 2,
|
||||||
"SuspendedPaymentCancel": 4,
|
"EscrowCancel": 4,
|
||||||
"PaymentChannelCreate": 13,
|
"PaymentChannelCreate": 13,
|
||||||
"PaymentChannelFund": 14,
|
"PaymentChannelFund": 14,
|
||||||
"PaymentChannelClaim": 15,
|
"PaymentChannelClaim": 15,
|
||||||
|
|||||||
@@ -15,6 +15,20 @@ const SignerListSet = {
|
|||||||
binary: require('./fixtures/signerlistset-tx-binary.json'),
|
binary: require('./fixtures/signerlistset-tx-binary.json'),
|
||||||
meta: require('./fixtures/signerlistset-tx-meta-binary.json')
|
meta: require('./fixtures/signerlistset-tx-meta-binary.json')
|
||||||
};
|
};
|
||||||
|
const Escrow = {
|
||||||
|
create: {
|
||||||
|
tx: require('./fixtures/escrow-create-tx.json'),
|
||||||
|
binary: require('./fixtures/escrow-create-binary.json')
|
||||||
|
},
|
||||||
|
finish: {
|
||||||
|
tx: require('./fixtures/escrow-finish-tx.json'),
|
||||||
|
binary: require('./fixtures/escrow-finish-binary.json')
|
||||||
|
},
|
||||||
|
cancel: {
|
||||||
|
tx: require('./fixtures/escrow-cancel-tx.json'),
|
||||||
|
binary: require('./fixtures/escrow-cancel-binary.json')
|
||||||
|
}
|
||||||
|
}
|
||||||
const PaymentChannel = {
|
const PaymentChannel = {
|
||||||
create: {
|
create: {
|
||||||
tx: require('./fixtures/payment-channel-create-tx.json'),
|
tx: require('./fixtures/payment-channel-create-tx.json'),
|
||||||
@@ -120,6 +134,21 @@ function SignerListSetTest() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function EscrowTest() {
|
||||||
|
it('can serialize EscrowCreate', () => {
|
||||||
|
assert.strictEqual(encode(Escrow.create.tx),
|
||||||
|
Escrow.create.binary);
|
||||||
|
});
|
||||||
|
it('can serialize EscrowFinish', () => {
|
||||||
|
assert.strictEqual(encode(Escrow.finish.tx),
|
||||||
|
Escrow.finish.binary);
|
||||||
|
});
|
||||||
|
it('can serialize EscrowCancel', () => {
|
||||||
|
assert.strictEqual(encode(Escrow.cancel.tx),
|
||||||
|
Escrow.cancel.binary);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function PaymentChannelTest() {
|
function PaymentChannelTest() {
|
||||||
it('can serialize PaymentChannelCreate', () => {
|
it('can serialize PaymentChannelCreate', () => {
|
||||||
assert.strictEqual(encode(PaymentChannel.create.tx),
|
assert.strictEqual(encode(PaymentChannel.create.tx),
|
||||||
@@ -142,5 +171,6 @@ describe('Binary Serialization', function() {
|
|||||||
describe('BytesList', bytesListTest);
|
describe('BytesList', bytesListTest);
|
||||||
describe('DeliverMin', deliverMinTest);
|
describe('DeliverMin', deliverMinTest);
|
||||||
describe('SignerListSet', SignerListSetTest);
|
describe('SignerListSet', SignerListSetTest);
|
||||||
|
describe('Escrow', EscrowTest);
|
||||||
describe('PaymentChannel', PaymentChannelTest);
|
describe('PaymentChannel', PaymentChannelTest);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -681,7 +681,14 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type_name": "Blob",
|
"type_name": "Blob",
|
||||||
"name": "Proof",
|
"name": "Fulfillment",
|
||||||
|
"nth_of_type": 16,
|
||||||
|
"type": 7,
|
||||||
|
"expected_hex": "7010"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type_name": "Blob",
|
||||||
|
"name": "Condition",
|
||||||
"nth_of_type": 17,
|
"nth_of_type": 17,
|
||||||
"type": 7,
|
"type": 7,
|
||||||
"expected_hex": "7011"
|
"expected_hex": "7011"
|
||||||
@@ -2924,7 +2931,7 @@
|
|||||||
"expected_hex": "0000"
|
"expected_hex": "0000"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"test_json": "SuspendedPaymentCreate",
|
"test_json": "EscrowCreate",
|
||||||
"type_id": 1,
|
"type_id": 1,
|
||||||
"type_specialisation_field": "TransactionType",
|
"type_specialisation_field": "TransactionType",
|
||||||
"type": "UInt16",
|
"type": "UInt16",
|
||||||
@@ -2932,14 +2939,14 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"test_json": 1,
|
"test_json": 1,
|
||||||
"canonical_json": "SuspendedPaymentCreate",
|
"canonical_json": "EscrowCreate",
|
||||||
"type_id": 1,
|
"type_id": 1,
|
||||||
"type_specialisation_field": "TransactionType",
|
"type_specialisation_field": "TransactionType",
|
||||||
"type": "UInt16",
|
"type": "UInt16",
|
||||||
"expected_hex": "0001"
|
"expected_hex": "0001"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"test_json": "SuspendedPaymentFinish",
|
"test_json": "EscrowFinish",
|
||||||
"type_id": 1,
|
"type_id": 1,
|
||||||
"type_specialisation_field": "TransactionType",
|
"type_specialisation_field": "TransactionType",
|
||||||
"type": "UInt16",
|
"type": "UInt16",
|
||||||
@@ -2947,7 +2954,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"test_json": 2,
|
"test_json": 2,
|
||||||
"canonical_json": "SuspendedPaymentFinish",
|
"canonical_json": "EscrowFinish",
|
||||||
"type_id": 1,
|
"type_id": 1,
|
||||||
"type_specialisation_field": "TransactionType",
|
"type_specialisation_field": "TransactionType",
|
||||||
"type": "UInt16",
|
"type": "UInt16",
|
||||||
@@ -2969,7 +2976,7 @@
|
|||||||
"expected_hex": "0003"
|
"expected_hex": "0003"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"test_json": "SuspendedPaymentCancel",
|
"test_json": "EscrowCancel",
|
||||||
"type_id": 1,
|
"type_id": 1,
|
||||||
"type_specialisation_field": "TransactionType",
|
"type_specialisation_field": "TransactionType",
|
||||||
"type": "UInt16",
|
"type": "UInt16",
|
||||||
@@ -2977,7 +2984,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"test_json": 4,
|
"test_json": 4,
|
||||||
"canonical_json": "SuspendedPaymentCancel",
|
"canonical_json": "EscrowCancel",
|
||||||
"type_id": 1,
|
"type_id": 1,
|
||||||
"type_specialisation_field": "TransactionType",
|
"type_specialisation_field": "TransactionType",
|
||||||
"type": "UInt16",
|
"type": "UInt16",
|
||||||
|
|||||||
1
packages/ripple-binary-codec/test/fixtures/escrow-cancel-binary.json
vendored
Normal file
1
packages/ripple-binary-codec/test/fixtures/escrow-cancel-binary.json
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
"1200042019000000198114EE5F7CF61504C7CF7E0C22562EB19CC7ACB0FCBA8214EE5F7CF61504C7CF7E0C22562EB19CC7ACB0FCBA"
|
||||||
6
packages/ripple-binary-codec/test/fixtures/escrow-cancel-tx.json
vendored
Normal file
6
packages/ripple-binary-codec/test/fixtures/escrow-cancel-tx.json
vendored
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"Account" : "r4jQDHCUvgcBAa5EzcB1D8BHGcjYP9eBC2",
|
||||||
|
"OfferSequence" : 25,
|
||||||
|
"Owner" : "r4jQDHCUvgcBAa5EzcB1D8BHGcjYP9eBC2",
|
||||||
|
"TransactionType" : "EscrowCancel"
|
||||||
|
}
|
||||||
1
packages/ripple-binary-codec/test/fixtures/escrow-create-binary.json
vendored
Normal file
1
packages/ripple-binary-codec/test/fixtures/escrow-create-binary.json
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
"1200012E00005BB82024258D09812025258D0980614000000000000064701127A0258020E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B8558101008114EE5F7CF61504C7CF7E0C22562EB19CC7ACB0FCBA8314B5F762798A53D543A014CAF8B297CFF8F2F937E8"
|
||||||
10
packages/ripple-binary-codec/test/fixtures/escrow-create-tx.json
vendored
Normal file
10
packages/ripple-binary-codec/test/fixtures/escrow-create-tx.json
vendored
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"Account" : "r4jQDHCUvgcBAa5EzcB1D8BHGcjYP9eBC2",
|
||||||
|
"Amount" : "100",
|
||||||
|
"CancelAfter" : 630000001,
|
||||||
|
"Condition" : "A0258020E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855810100",
|
||||||
|
"Destination" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
|
||||||
|
"DestinationTag" : 23480,
|
||||||
|
"FinishAfter" : 630000000,
|
||||||
|
"TransactionType": "EscrowCreate"
|
||||||
|
}
|
||||||
1
packages/ripple-binary-codec/test/fixtures/escrow-finish-binary.json
vendored
Normal file
1
packages/ripple-binary-codec/test/fixtures/escrow-finish-binary.json
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
"120002201900000007701004A0028000701127A0258020E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B8558101008114EE5F7CF61504C7CF7E0C22562EB19CC7ACB0FCBA8214EE5F7CF61504C7CF7E0C22562EB19CC7ACB0FCBA"
|
||||||
8
packages/ripple-binary-codec/test/fixtures/escrow-finish-tx.json
vendored
Normal file
8
packages/ripple-binary-codec/test/fixtures/escrow-finish-tx.json
vendored
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"Account" : "r4jQDHCUvgcBAa5EzcB1D8BHGcjYP9eBC2",
|
||||||
|
"Condition" : "A0258020E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855810100",
|
||||||
|
"Fulfillment" : "A0028000",
|
||||||
|
"OfferSequence" : 7,
|
||||||
|
"Owner" : "r4jQDHCUvgcBAa5EzcB1D8BHGcjYP9eBC2",
|
||||||
|
"TransactionType" : "EscrowFinish"
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user