@ledgerhq/coin-canton 0.4.1-nightly.0 → 0.5.0-nightly.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +1 -1
- package/.unimportedrc.json +12 -4
- package/CHANGELOG.md +35 -0
- package/lib/api/getBalance.integ.test.js +1 -1
- package/lib/api/getBalance.integ.test.js.map +1 -1
- package/lib/api/index.d.ts.map +1 -1
- package/lib/api/index.js +12 -9
- package/lib/api/index.js.map +1 -1
- package/lib/bridge/createTransaction.test.js +1 -1
- package/lib/bridge/createTransaction.test.js.map +1 -1
- package/lib/bridge/index.d.ts +3 -3
- package/lib/bridge/index.d.ts.map +1 -1
- package/lib/bridge/index.js +9 -1
- package/lib/bridge/index.js.map +1 -1
- package/lib/bridge/onboard.d.ts +10 -0
- package/lib/bridge/onboard.d.ts.map +1 -0
- package/lib/bridge/onboard.integ.test.d.ts +2 -0
- package/lib/bridge/onboard.integ.test.d.ts.map +1 -0
- package/lib/bridge/onboard.integ.test.js +156 -0
- package/lib/bridge/onboard.integ.test.js.map +1 -0
- package/lib/bridge/onboard.js +139 -0
- package/lib/bridge/onboard.js.map +1 -0
- package/lib/bridge/prepareTransaction.d.ts.map +1 -1
- package/lib/bridge/prepareTransaction.js +5 -7
- package/lib/bridge/prepareTransaction.js.map +1 -1
- package/lib/bridge/signOperation.d.ts.map +1 -1
- package/lib/bridge/signOperation.js +2 -1
- package/lib/bridge/signOperation.js.map +1 -1
- package/lib/bridge/sync.d.ts.map +1 -1
- package/lib/bridge/sync.integ.test.d.ts +2 -0
- package/lib/bridge/sync.integ.test.d.ts.map +1 -0
- package/lib/bridge/sync.integ.test.js +175 -0
- package/lib/bridge/sync.integ.test.js.map +1 -0
- package/lib/bridge/sync.js +39 -36
- package/lib/bridge/sync.js.map +1 -1
- package/lib/bridge/updateTransaction.d.ts.map +1 -1
- package/lib/bridge/updateTransaction.js +0 -4
- package/lib/bridge/updateTransaction.js.map +1 -1
- package/lib/common-logic/history/listOperations.d.ts.map +1 -1
- package/lib/common-logic/history/listOperations.js +19 -31
- package/lib/common-logic/history/listOperations.js.map +1 -1
- package/lib/common-logic/transaction/craftTransaction.d.ts +4 -3
- package/lib/common-logic/transaction/craftTransaction.d.ts.map +1 -1
- package/lib/common-logic/transaction/craftTransaction.js +10 -12
- package/lib/common-logic/transaction/craftTransaction.js.map +1 -1
- package/lib/network/gateway.d.ts +194 -3
- package/lib/network/gateway.d.ts.map +1 -1
- package/lib/network/gateway.integ.test.js +121 -11
- package/lib/network/gateway.integ.test.js.map +1 -1
- package/lib/network/gateway.js +96 -18
- package/lib/network/gateway.js.map +1 -1
- package/lib/network/node.d.ts +2 -2
- package/lib/network/node.d.ts.map +1 -1
- package/lib/network/node.js.map +1 -1
- package/lib/network/types.d.ts +1 -1
- package/lib/network/types.d.ts.map +1 -1
- package/lib/signer/getAddress.d.ts.map +1 -1
- package/lib/signer/getAddress.js +2 -2
- package/lib/signer/getAddress.js.map +1 -1
- package/lib/test/cantonTestUtils.d.ts +33 -0
- package/lib/test/cantonTestUtils.d.ts.map +1 -0
- package/lib/test/cantonTestUtils.js +159 -0
- package/lib/test/cantonTestUtils.js.map +1 -0
- package/lib/types/bridge.d.ts +7 -1
- package/lib/types/bridge.d.ts.map +1 -1
- package/lib/types/index.d.ts +1 -10
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/index.js +1 -0
- package/lib/types/index.js.map +1 -1
- package/lib/types/onboard.d.ts +55 -0
- package/lib/types/onboard.d.ts.map +1 -0
- package/lib/types/onboard.js +22 -0
- package/lib/types/onboard.js.map +1 -0
- package/lib-es/api/getBalance.integ.test.js +1 -1
- package/lib-es/api/getBalance.integ.test.js.map +1 -1
- package/lib-es/api/index.d.ts.map +1 -1
- package/lib-es/api/index.js +13 -10
- package/lib-es/api/index.js.map +1 -1
- package/lib-es/bridge/createTransaction.test.js +1 -1
- package/lib-es/bridge/createTransaction.test.js.map +1 -1
- package/lib-es/bridge/index.d.ts +3 -3
- package/lib-es/bridge/index.d.ts.map +1 -1
- package/lib-es/bridge/index.js +9 -1
- package/lib-es/bridge/index.js.map +1 -1
- package/lib-es/bridge/onboard.d.ts +10 -0
- package/lib-es/bridge/onboard.d.ts.map +1 -0
- package/lib-es/bridge/onboard.integ.test.d.ts +2 -0
- package/lib-es/bridge/onboard.integ.test.d.ts.map +1 -0
- package/lib-es/bridge/onboard.integ.test.js +151 -0
- package/lib-es/bridge/onboard.integ.test.js.map +1 -0
- package/lib-es/bridge/onboard.js +133 -0
- package/lib-es/bridge/onboard.js.map +1 -0
- package/lib-es/bridge/prepareTransaction.d.ts.map +1 -1
- package/lib-es/bridge/prepareTransaction.js +6 -8
- package/lib-es/bridge/prepareTransaction.js.map +1 -1
- package/lib-es/bridge/signOperation.d.ts.map +1 -1
- package/lib-es/bridge/signOperation.js +2 -1
- package/lib-es/bridge/signOperation.js.map +1 -1
- package/lib-es/bridge/sync.d.ts.map +1 -1
- package/lib-es/bridge/sync.integ.test.d.ts +2 -0
- package/lib-es/bridge/sync.integ.test.d.ts.map +1 -0
- package/lib-es/bridge/sync.integ.test.js +137 -0
- package/lib-es/bridge/sync.integ.test.js.map +1 -0
- package/lib-es/bridge/sync.js +38 -35
- package/lib-es/bridge/sync.js.map +1 -1
- package/lib-es/bridge/updateTransaction.d.ts.map +1 -1
- package/lib-es/bridge/updateTransaction.js +0 -4
- package/lib-es/bridge/updateTransaction.js.map +1 -1
- package/lib-es/common-logic/history/listOperations.d.ts.map +1 -1
- package/lib-es/common-logic/history/listOperations.js +20 -29
- package/lib-es/common-logic/history/listOperations.js.map +1 -1
- package/lib-es/common-logic/transaction/craftTransaction.d.ts +4 -3
- package/lib-es/common-logic/transaction/craftTransaction.d.ts.map +1 -1
- package/lib-es/common-logic/transaction/craftTransaction.js +10 -12
- package/lib-es/common-logic/transaction/craftTransaction.js.map +1 -1
- package/lib-es/network/gateway.d.ts +194 -3
- package/lib-es/network/gateway.d.ts.map +1 -1
- package/lib-es/network/gateway.integ.test.js +122 -12
- package/lib-es/network/gateway.integ.test.js.map +1 -1
- package/lib-es/network/gateway.js +90 -17
- package/lib-es/network/gateway.js.map +1 -1
- package/lib-es/network/node.d.ts +2 -2
- package/lib-es/network/node.d.ts.map +1 -1
- package/lib-es/network/node.js.map +1 -1
- package/lib-es/network/types.d.ts +1 -1
- package/lib-es/network/types.d.ts.map +1 -1
- package/lib-es/signer/getAddress.d.ts.map +1 -1
- package/lib-es/signer/getAddress.js +2 -2
- package/lib-es/signer/getAddress.js.map +1 -1
- package/lib-es/test/cantonTestUtils.d.ts +33 -0
- package/lib-es/test/cantonTestUtils.d.ts.map +1 -0
- package/lib-es/test/cantonTestUtils.js +151 -0
- package/lib-es/test/cantonTestUtils.js.map +1 -0
- package/lib-es/types/bridge.d.ts +7 -1
- package/lib-es/types/bridge.d.ts.map +1 -1
- package/lib-es/types/index.d.ts +1 -10
- package/lib-es/types/index.d.ts.map +1 -1
- package/lib-es/types/index.js +1 -0
- package/lib-es/types/index.js.map +1 -1
- package/lib-es/types/onboard.d.ts +55 -0
- package/lib-es/types/onboard.d.ts.map +1 -0
- package/lib-es/types/onboard.js +19 -0
- package/lib-es/types/onboard.js.map +1 -0
- package/package.json +6 -6
- package/src/api/getBalance.integ.test.ts +1 -2
- package/src/api/index.ts +33 -25
- package/src/bridge/createTransaction.test.ts +1 -1
- package/src/bridge/index.ts +14 -4
- package/src/bridge/onboard.integ.test.ts +219 -0
- package/src/bridge/onboard.ts +220 -0
- package/src/bridge/prepareTransaction.ts +6 -15
- package/src/bridge/signOperation.ts +3 -2
- package/src/bridge/sync.integ.test.ts +180 -0
- package/src/bridge/sync.ts +57 -49
- package/src/bridge/updateTransaction.ts +0 -5
- package/src/common-logic/history/listOperations.ts +20 -31
- package/src/common-logic/transaction/craftTransaction.ts +13 -17
- package/src/network/gateway.integ.test.ts +156 -17
- package/src/network/gateway.ts +333 -26
- package/src/network/node.ts +3 -3
- package/src/network/types.ts +1 -1
- package/src/signer/getAddress.ts +3 -5
- package/src/test/cantonTestUtils.ts +181 -0
- package/src/types/bridge.ts +20 -0
- package/src/types/index.ts +1 -11
- package/src/types/onboard.ts +65 -0
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
import type { Operation, Pagination } from "@ledgerhq/coin-framework/api/index";
|
|
2
|
-
import {
|
|
2
|
+
import { getOperations } from "../../network/gateway";
|
|
3
3
|
import coinConfig from "../../config";
|
|
4
4
|
|
|
5
|
-
const getNativeContractId = () =>
|
|
6
|
-
coinConfig.getCoinConfig().nativeInstrumentId !== undefined
|
|
7
|
-
? coinConfig.getCoinConfig().nativeInstrumentId?.split(".")[0]
|
|
8
|
-
: "";
|
|
9
|
-
|
|
10
5
|
/**
|
|
11
6
|
* Returns list of operations associated to an account.
|
|
12
7
|
* @param partyId Account partyId
|
|
@@ -18,37 +13,31 @@ export async function listOperations(
|
|
|
18
13
|
partyId: string,
|
|
19
14
|
page: Pagination,
|
|
20
15
|
): Promise<[Operation[], string]> {
|
|
21
|
-
const {
|
|
16
|
+
const { operations, next } = await getOperations(partyId, {
|
|
22
17
|
cursor: page.pagingToken !== undefined ? parseInt(page.pagingToken) : undefined,
|
|
23
18
|
minOffset: page.minHeight,
|
|
24
19
|
limit: page.limit,
|
|
25
20
|
});
|
|
26
21
|
const ops: Operation[] = [];
|
|
27
|
-
for (const tx of
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
fees: BigInt(0), // to be finalized when details are available on backend
|
|
44
|
-
date: new Date(tx.record_time.seconds),
|
|
45
|
-
block: {
|
|
46
|
-
height: tx.offset,
|
|
47
|
-
time: new Date(tx.effective_at.seconds),
|
|
48
|
-
},
|
|
22
|
+
for (const tx of operations) {
|
|
23
|
+
if (tx.type === "Send") {
|
|
24
|
+
ops.push({
|
|
25
|
+
id: tx.uid,
|
|
26
|
+
type: tx.senders.includes(partyId) ? "OUT" : "IN",
|
|
27
|
+
value: BigInt(tx.transfers[0].value),
|
|
28
|
+
senders: tx.senders,
|
|
29
|
+
recipients: tx.recipients,
|
|
30
|
+
asset: tx.asset,
|
|
31
|
+
tx: {
|
|
32
|
+
hash: tx.block.hash,
|
|
33
|
+
fees: BigInt(tx.fee.value),
|
|
34
|
+
date: new Date(tx.transaction_timestamp),
|
|
35
|
+
block: {
|
|
36
|
+
height: tx.block.height,
|
|
37
|
+
time: new Date(tx.block.time),
|
|
49
38
|
},
|
|
50
|
-
}
|
|
51
|
-
}
|
|
39
|
+
},
|
|
40
|
+
});
|
|
52
41
|
}
|
|
53
42
|
}
|
|
54
43
|
return [ops, next + ""];
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import BigNumber from "bignumber.js";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
const encodeNativeTx = (nativeTx: BoilerplateNativeTransaction) => JSON.stringify(nativeTx);
|
|
2
|
+
import { prepareTransferRequest, PrepareTransferResponse } from "../../network/gateway";
|
|
5
3
|
|
|
6
4
|
export async function craftTransaction(
|
|
7
5
|
account: {
|
|
@@ -12,25 +10,23 @@ export async function craftTransaction(
|
|
|
12
10
|
transaction: {
|
|
13
11
|
recipient?: string;
|
|
14
12
|
amount: BigNumber;
|
|
15
|
-
|
|
13
|
+
tokenId: string;
|
|
14
|
+
expireInSeconds: number;
|
|
16
15
|
},
|
|
17
16
|
): Promise<{
|
|
18
|
-
nativeTransaction:
|
|
17
|
+
nativeTransaction: PrepareTransferResponse;
|
|
19
18
|
serializedTransaction: string;
|
|
20
19
|
}> {
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
const serializedTransaction = encodeNativeTx(nativeTransaction);
|
|
20
|
+
const { serialized, json } = await prepareTransferRequest(account.address, {
|
|
21
|
+
recipient: transaction.recipient || "",
|
|
22
|
+
amount: transaction.amount.toNumber(),
|
|
23
|
+
type: "token-transfer-request",
|
|
24
|
+
execute_before_secs: transaction.expireInSeconds,
|
|
25
|
+
instrument_id: transaction.tokenId,
|
|
26
|
+
});
|
|
31
27
|
|
|
32
28
|
return {
|
|
33
|
-
nativeTransaction,
|
|
34
|
-
serializedTransaction,
|
|
29
|
+
nativeTransaction: json,
|
|
30
|
+
serializedTransaction: serialized,
|
|
35
31
|
};
|
|
36
32
|
}
|
|
@@ -1,15 +1,26 @@
|
|
|
1
1
|
import coinConfig from "../config";
|
|
2
|
+
import { generateMockKeyPair } from "../test/cantonTestUtils";
|
|
2
3
|
import {
|
|
3
4
|
getLedgerEnd,
|
|
4
5
|
prepareOnboarding,
|
|
5
6
|
getBalance,
|
|
6
|
-
|
|
7
|
+
getOperations,
|
|
7
8
|
getPartyById,
|
|
8
9
|
getPartyByPubKey,
|
|
10
|
+
submitOnboarding,
|
|
11
|
+
prepareTapRequest,
|
|
12
|
+
submitTapRequest,
|
|
13
|
+
preparePreApprovalTransaction,
|
|
14
|
+
submitPreApprovalTransaction,
|
|
9
15
|
} from "./gateway";
|
|
10
16
|
|
|
11
17
|
describe("gateway (devnet)", () => {
|
|
12
|
-
|
|
18
|
+
let onboardedAccount: {
|
|
19
|
+
keyPair: ReturnType<typeof generateMockKeyPair>;
|
|
20
|
+
partyId: string;
|
|
21
|
+
} | null = null;
|
|
22
|
+
|
|
23
|
+
beforeAll(async () => {
|
|
13
24
|
coinConfig.setCoinConfig(() => ({
|
|
14
25
|
gatewayUrl: "https://canton-gateway.api.live.ledger-test.com",
|
|
15
26
|
useGateway: true,
|
|
@@ -18,18 +29,63 @@ describe("gateway (devnet)", () => {
|
|
|
18
29
|
type: "active",
|
|
19
30
|
},
|
|
20
31
|
}));
|
|
21
|
-
});
|
|
32
|
+
}, 60000);
|
|
33
|
+
|
|
34
|
+
const getOnboardedAccount = () => {
|
|
35
|
+
if (!onboardedAccount) {
|
|
36
|
+
throw new Error("Shared onboarded account not available. Check beforeAll setup.");
|
|
37
|
+
}
|
|
38
|
+
return onboardedAccount;
|
|
39
|
+
};
|
|
22
40
|
|
|
23
41
|
describe("prepareOnboarding", () => {
|
|
24
42
|
it("should prepare onboarding", async () => {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
43
|
+
// GIVEN
|
|
44
|
+
const keyPair = generateMockKeyPair();
|
|
45
|
+
|
|
46
|
+
// Save onboarded account for all tests that need a valid party ID
|
|
47
|
+
onboardedAccount = {
|
|
48
|
+
keyPair,
|
|
49
|
+
partyId: "", // set in next test
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
// WHEN
|
|
53
|
+
const response = await prepareOnboarding(keyPair.publicKeyHex, "ed25519");
|
|
54
|
+
|
|
55
|
+
// THEN
|
|
29
56
|
expect(response).toHaveProperty("party_id");
|
|
30
57
|
expect(response).toHaveProperty("party_name");
|
|
31
58
|
expect(response).toHaveProperty("public_key_fingerprint");
|
|
32
|
-
expect(response).toHaveProperty("
|
|
59
|
+
expect(response).toHaveProperty("transactions");
|
|
60
|
+
expect(response.transactions).toHaveProperty("combined_hash");
|
|
61
|
+
expect(response.party_name).toBe(keyPair.publicKeyHex);
|
|
62
|
+
|
|
63
|
+
expect(response.public_key_fingerprint).toBe(keyPair.fingerprint);
|
|
64
|
+
}, 30000);
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
describe("submitOnboarding", () => {
|
|
68
|
+
it("should submit onboarding with proper signature", async () => {
|
|
69
|
+
// GIVEN
|
|
70
|
+
const { keyPair } = getOnboardedAccount();
|
|
71
|
+
const prepareRequest = { public_key: keyPair.publicKeyHex, public_key_type: "ed25519" };
|
|
72
|
+
const prepareResponse = await prepareOnboarding(keyPair.publicKeyHex, "ed25519");
|
|
73
|
+
const signature = keyPair.sign(prepareResponse.transactions.combined_hash);
|
|
74
|
+
|
|
75
|
+
// WHEN
|
|
76
|
+
const response = await submitOnboarding(prepareRequest, prepareResponse, signature);
|
|
77
|
+
|
|
78
|
+
// Save onboarded account for all tests that need a valid party ID
|
|
79
|
+
onboardedAccount = {
|
|
80
|
+
keyPair,
|
|
81
|
+
partyId: response.party.party_id,
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
// THEN
|
|
85
|
+
expect(response).toHaveProperty("party");
|
|
86
|
+
expect(response.party).toHaveProperty("party_id");
|
|
87
|
+
expect(response.party).toHaveProperty("public_key");
|
|
88
|
+
expect(response.party.public_key).toBe(keyPair.publicKeyHex);
|
|
33
89
|
}, 30000);
|
|
34
90
|
});
|
|
35
91
|
|
|
@@ -42,12 +98,13 @@ describe("gateway (devnet)", () => {
|
|
|
42
98
|
|
|
43
99
|
describe("getBalance", () => {
|
|
44
100
|
it("should return user balance", async () => {
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
);
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
101
|
+
const { partyId } = getOnboardedAccount();
|
|
102
|
+
const balance = await getBalance(partyId);
|
|
103
|
+
expect(balance.length).toBeGreaterThanOrEqual(0);
|
|
104
|
+
if (balance.length > 0) {
|
|
105
|
+
expect(balance[0].amount).toBeGreaterThanOrEqual(0);
|
|
106
|
+
expect(balance[0]).toHaveProperty("instrument_id");
|
|
107
|
+
}
|
|
51
108
|
});
|
|
52
109
|
});
|
|
53
110
|
|
|
@@ -67,12 +124,94 @@ describe("gateway (devnet)", () => {
|
|
|
67
124
|
});
|
|
68
125
|
});
|
|
69
126
|
|
|
70
|
-
describe("
|
|
127
|
+
describe("getOperations", () => {
|
|
71
128
|
it("should return user transactions", async () => {
|
|
72
|
-
const {
|
|
129
|
+
const { operations } = await getOperations(
|
|
73
130
|
"party-5f29bb32e9939939::12202becd8062a1d170209956cfd977fca76fcb4d2a892d08c77a7483f35a11d6440",
|
|
74
131
|
);
|
|
75
|
-
expect(
|
|
132
|
+
expect(operations.length).toBeGreaterThanOrEqual(0);
|
|
76
133
|
});
|
|
77
134
|
});
|
|
135
|
+
|
|
136
|
+
describe("prepareTapRequest", () => {
|
|
137
|
+
it("should prepare tap request for onboarded party", async () => {
|
|
138
|
+
// GIVEN
|
|
139
|
+
const { partyId } = getOnboardedAccount();
|
|
140
|
+
const amount = 1000;
|
|
141
|
+
|
|
142
|
+
// WHEN
|
|
143
|
+
const response = await prepareTapRequest({ partyId, amount });
|
|
144
|
+
|
|
145
|
+
// THEN
|
|
146
|
+
expect(response).toHaveProperty("serialized");
|
|
147
|
+
expect(response).toHaveProperty("hash");
|
|
148
|
+
expect(typeof response.serialized).toBe("string");
|
|
149
|
+
expect(typeof response.hash).toBe("string");
|
|
150
|
+
}, 30000);
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
describe("submitTapRequest", () => {
|
|
154
|
+
it("should submit tap request with proper signature", async () => {
|
|
155
|
+
// GIVEN
|
|
156
|
+
const { keyPair, partyId } = getOnboardedAccount();
|
|
157
|
+
const tapPrepareResponse = await prepareTapRequest({
|
|
158
|
+
partyId,
|
|
159
|
+
amount: 1000,
|
|
160
|
+
});
|
|
161
|
+
const tapSignature = keyPair.sign(tapPrepareResponse.hash);
|
|
162
|
+
|
|
163
|
+
// WHEN
|
|
164
|
+
const response = await submitTapRequest({
|
|
165
|
+
partyId,
|
|
166
|
+
serialized: tapPrepareResponse.serialized,
|
|
167
|
+
signature: tapSignature,
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
// THEN
|
|
171
|
+
expect(response).toHaveProperty("submission_id");
|
|
172
|
+
expect(response).toHaveProperty("update_id");
|
|
173
|
+
expect(typeof response.submission_id).toBe("string");
|
|
174
|
+
expect(typeof response.update_id).toBe("string");
|
|
175
|
+
}, 30000);
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
describe("preparePreApprovalTransaction", () => {
|
|
179
|
+
it("should prepare pre-approval transaction for onboarded party", async () => {
|
|
180
|
+
// GIVEN
|
|
181
|
+
const { partyId } = getOnboardedAccount();
|
|
182
|
+
|
|
183
|
+
// WHEN
|
|
184
|
+
const response = await preparePreApprovalTransaction(partyId);
|
|
185
|
+
|
|
186
|
+
// THEN
|
|
187
|
+
expect(response).toHaveProperty("serialized");
|
|
188
|
+
expect(response).toHaveProperty("hash");
|
|
189
|
+
expect(typeof response.serialized).toBe("string");
|
|
190
|
+
expect(typeof response.hash).toBe("string");
|
|
191
|
+
}, 30000);
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
describe("submitPreApprovalTransaction", () => {
|
|
195
|
+
it("should submit pre-approval transaction with proper signature", async () => {
|
|
196
|
+
// GIVEN
|
|
197
|
+
const { keyPair, partyId } = getOnboardedAccount();
|
|
198
|
+
const preparedTransaction = await preparePreApprovalTransaction(partyId);
|
|
199
|
+
const preApprovalSignature = keyPair.sign(preparedTransaction.hash);
|
|
200
|
+
|
|
201
|
+
// WHEN
|
|
202
|
+
const response = await submitPreApprovalTransaction(
|
|
203
|
+
partyId,
|
|
204
|
+
preparedTransaction,
|
|
205
|
+
preApprovalSignature,
|
|
206
|
+
);
|
|
207
|
+
|
|
208
|
+
// THEN
|
|
209
|
+
expect(response).toHaveProperty("isApproved");
|
|
210
|
+
expect(response).toHaveProperty("submissionId");
|
|
211
|
+
expect(response).toHaveProperty("updateId");
|
|
212
|
+
expect(response.isApproved).toBe(true);
|
|
213
|
+
expect(typeof response.submissionId).toBe("string");
|
|
214
|
+
expect(typeof response.updateId).toBe("string");
|
|
215
|
+
}, 30000);
|
|
216
|
+
});
|
|
78
217
|
});
|