@ledgerhq/coin-canton 0.5.0-nightly.4 → 0.5.0
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/CHANGELOG.md +36 -39
- package/lib/api/getBalance.integ.test.js +4 -8
- package/lib/api/getBalance.integ.test.js.map +1 -1
- package/lib/api/index.d.ts.map +1 -1
- package/lib/api/index.js +8 -11
- package/lib/api/index.js.map +1 -1
- package/lib/bridge/broadcast.d.ts.map +1 -1
- package/lib/bridge/broadcast.js +1 -2
- package/lib/bridge/broadcast.js.map +1 -1
- package/lib/bridge/index.d.ts.map +1 -1
- package/lib/bridge/index.js +0 -3
- package/lib/bridge/index.js.map +1 -1
- package/lib/bridge/onboard.d.ts +3 -4
- package/lib/bridge/onboard.d.ts.map +1 -1
- package/lib/bridge/onboard.integ.test.js +3 -3
- package/lib/bridge/onboard.integ.test.js.map +1 -1
- package/lib/bridge/onboard.js +35 -95
- package/lib/bridge/onboard.js.map +1 -1
- package/lib/bridge/prepareTransaction.d.ts.map +1 -1
- package/lib/bridge/prepareTransaction.js +7 -5
- package/lib/bridge/prepareTransaction.js.map +1 -1
- package/lib/bridge/signOperation.d.ts.map +1 -1
- package/lib/bridge/signOperation.js +9 -7
- package/lib/bridge/signOperation.js.map +1 -1
- package/lib/bridge/sync.d.ts +1 -2
- package/lib/bridge/sync.d.ts.map +1 -1
- package/lib/bridge/sync.js +15 -30
- package/lib/bridge/sync.js.map +1 -1
- package/lib/bridge/updateTransaction.d.ts.map +1 -1
- package/lib/bridge/updateTransaction.js +4 -0
- package/lib/bridge/updateTransaction.js.map +1 -1
- package/lib/common-logic/transaction/broadcast.d.ts.map +1 -1
- package/lib/common-logic/transaction/broadcast.js +1 -2
- package/lib/common-logic/transaction/broadcast.js.map +1 -1
- package/lib/common-logic/transaction/broadcast.test.js +3 -3
- package/lib/common-logic/transaction/broadcast.test.js.map +1 -1
- package/lib/common-logic/transaction/combine.d.ts +1 -1
- package/lib/common-logic/transaction/combine.d.ts.map +1 -1
- package/lib/common-logic/transaction/combine.js +3 -2
- package/lib/common-logic/transaction/combine.js.map +1 -1
- package/lib/common-logic/transaction/combine.test.js +13 -3
- package/lib/common-logic/transaction/combine.test.js.map +1 -1
- package/lib/common-logic/transaction/craftTransaction.d.ts +3 -5
- package/lib/common-logic/transaction/craftTransaction.d.ts.map +1 -1
- package/lib/common-logic/transaction/craftTransaction.js +12 -11
- package/lib/common-logic/transaction/craftTransaction.js.map +1 -1
- package/lib/common-logic/transaction/estimateFees.d.ts.map +1 -1
- package/lib/common-logic/transaction/estimateFees.js +1 -6
- package/lib/common-logic/transaction/estimateFees.js.map +1 -1
- package/lib/config.d.ts +0 -1
- package/lib/config.d.ts.map +1 -1
- package/lib/config.js.map +1 -1
- package/lib/network/gateway.d.ts +8 -22
- package/lib/network/gateway.d.ts.map +1 -1
- package/lib/network/gateway.integ.test.js +1 -2
- package/lib/network/gateway.integ.test.js.map +1 -1
- package/lib/network/gateway.js +24 -50
- 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/types/bridge.d.ts +1 -13
- package/lib/types/bridge.d.ts.map +1 -1
- package/lib/types/index.d.ts +10 -0
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/onboard.d.ts +0 -2
- package/lib/types/onboard.d.ts.map +1 -1
- package/lib/types/onboard.js.map +1 -1
- package/lib/types/signer.d.ts +1 -2
- package/lib/types/signer.d.ts.map +1 -1
- package/lib-es/api/getBalance.integ.test.js +4 -8
- 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 +9 -12
- package/lib-es/api/index.js.map +1 -1
- package/lib-es/bridge/broadcast.d.ts.map +1 -1
- package/lib-es/bridge/broadcast.js +1 -2
- package/lib-es/bridge/broadcast.js.map +1 -1
- package/lib-es/bridge/index.d.ts.map +1 -1
- package/lib-es/bridge/index.js +0 -3
- package/lib-es/bridge/index.js.map +1 -1
- package/lib-es/bridge/onboard.d.ts +3 -4
- package/lib-es/bridge/onboard.d.ts.map +1 -1
- package/lib-es/bridge/onboard.integ.test.js +3 -3
- package/lib-es/bridge/onboard.integ.test.js.map +1 -1
- package/lib-es/bridge/onboard.js +35 -92
- package/lib-es/bridge/onboard.js.map +1 -1
- package/lib-es/bridge/prepareTransaction.d.ts.map +1 -1
- package/lib-es/bridge/prepareTransaction.js +8 -6
- 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 +10 -8
- package/lib-es/bridge/signOperation.js.map +1 -1
- package/lib-es/bridge/sync.d.ts +1 -2
- package/lib-es/bridge/sync.d.ts.map +1 -1
- package/lib-es/bridge/sync.js +16 -31
- 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 +4 -0
- package/lib-es/bridge/updateTransaction.js.map +1 -1
- package/lib-es/common-logic/transaction/broadcast.d.ts.map +1 -1
- package/lib-es/common-logic/transaction/broadcast.js +1 -2
- package/lib-es/common-logic/transaction/broadcast.js.map +1 -1
- package/lib-es/common-logic/transaction/broadcast.test.js +3 -3
- package/lib-es/common-logic/transaction/broadcast.test.js.map +1 -1
- package/lib-es/common-logic/transaction/combine.d.ts +1 -1
- package/lib-es/common-logic/transaction/combine.d.ts.map +1 -1
- package/lib-es/common-logic/transaction/combine.js +3 -2
- package/lib-es/common-logic/transaction/combine.js.map +1 -1
- package/lib-es/common-logic/transaction/combine.test.js +13 -3
- package/lib-es/common-logic/transaction/combine.test.js.map +1 -1
- package/lib-es/common-logic/transaction/craftTransaction.d.ts +3 -5
- package/lib-es/common-logic/transaction/craftTransaction.d.ts.map +1 -1
- package/lib-es/common-logic/transaction/craftTransaction.js +12 -11
- package/lib-es/common-logic/transaction/craftTransaction.js.map +1 -1
- package/lib-es/common-logic/transaction/estimateFees.d.ts.map +1 -1
- package/lib-es/common-logic/transaction/estimateFees.js +1 -3
- package/lib-es/common-logic/transaction/estimateFees.js.map +1 -1
- package/lib-es/config.d.ts +0 -1
- package/lib-es/config.d.ts.map +1 -1
- package/lib-es/config.js.map +1 -1
- package/lib-es/network/gateway.d.ts +8 -22
- package/lib-es/network/gateway.d.ts.map +1 -1
- package/lib-es/network/gateway.integ.test.js +1 -2
- package/lib-es/network/gateway.integ.test.js.map +1 -1
- package/lib-es/network/gateway.js +24 -49
- 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/types/bridge.d.ts +1 -13
- package/lib-es/types/bridge.d.ts.map +1 -1
- package/lib-es/types/index.d.ts +10 -0
- package/lib-es/types/index.d.ts.map +1 -1
- package/lib-es/types/onboard.d.ts +0 -2
- package/lib-es/types/onboard.d.ts.map +1 -1
- package/lib-es/types/onboard.js.map +1 -1
- package/lib-es/types/signer.d.ts +1 -2
- package/lib-es/types/signer.d.ts.map +1 -1
- package/package.json +7 -7
- package/src/api/getBalance.integ.test.ts +5 -8
- package/src/api/index.ts +26 -33
- package/src/bridge/broadcast.ts +3 -2
- package/src/bridge/index.ts +0 -3
- package/src/bridge/onboard.integ.test.ts +3 -3
- package/src/bridge/onboard.ts +47 -120
- package/src/bridge/prepareTransaction.ts +15 -6
- package/src/bridge/signOperation.ts +16 -9
- package/src/bridge/sync.ts +19 -42
- package/src/bridge/updateTransaction.ts +5 -0
- package/src/common-logic/transaction/broadcast.test.ts +3 -3
- package/src/common-logic/transaction/broadcast.ts +1 -2
- package/src/common-logic/transaction/combine.test.ts +13 -3
- package/src/common-logic/transaction/combine.ts +4 -2
- package/src/common-logic/transaction/craftTransaction.ts +17 -15
- package/src/common-logic/transaction/estimateFees.ts +1 -5
- package/src/config.ts +0 -1
- package/src/network/gateway.integ.test.ts +1 -2
- package/src/network/gateway.ts +36 -84
- package/src/network/node.ts +3 -3
- package/src/network/types.ts +1 -1
- package/src/signer/getAddress.ts +4 -6
- package/src/types/bridge.ts +0 -16
- package/src/types/index.ts +11 -0
- package/src/types/onboard.ts +0 -3
- package/src/types/signer.ts +1 -2
- package/lib/bridge/serialization.d.ts +0 -4
- package/lib/bridge/serialization.d.ts.map +0 -1
- package/lib/bridge/serialization.js +0 -31
- package/lib/bridge/serialization.js.map +0 -1
- package/lib/bridge/sync.integ.test.d.ts +0 -2
- package/lib/bridge/sync.integ.test.d.ts.map +0 -1
- package/lib/bridge/sync.integ.test.js +0 -175
- package/lib/bridge/sync.integ.test.js.map +0 -1
- package/lib-es/bridge/serialization.d.ts +0 -4
- package/lib-es/bridge/serialization.d.ts.map +0 -1
- package/lib-es/bridge/serialization.js +0 -27
- package/lib-es/bridge/serialization.js.map +0 -1
- package/lib-es/bridge/sync.integ.test.d.ts +0 -2
- package/lib-es/bridge/sync.integ.test.d.ts.map +0 -1
- package/lib-es/bridge/sync.integ.test.js +0 -137
- package/lib-es/bridge/sync.integ.test.js.map +0 -1
- package/src/bridge/serialization.ts +0 -36
- package/src/bridge/sync.integ.test.ts +0 -180
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AAEzB,MAAM,MAAM,4BAA4B,GAAG;IACzC,eAAe,EAAE,SAAS,CAAC;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Account } from "@ledgerhq/types-live";
|
|
2
1
|
export declare enum OnboardStatus {
|
|
3
2
|
INIT = 0,
|
|
4
3
|
PREPARE = 1,
|
|
@@ -20,7 +19,6 @@ export type CantonOnboardProgress = {
|
|
|
20
19
|
};
|
|
21
20
|
export type CantonOnboardResult = {
|
|
22
21
|
partyId: string;
|
|
23
|
-
account: Partial<Account>;
|
|
24
22
|
};
|
|
25
23
|
export type CantonPreApprovalProgress = {
|
|
26
24
|
status: PreApprovalStatus;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"onboard.d.ts","sourceRoot":"","sources":["../../src/types/onboard.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"onboard.d.ts","sourceRoot":"","sources":["../../src/types/onboard.ts"],"names":[],"mappings":"AAAA,oBAAY,aAAa;IACvB,IAAI,IAAA;IACJ,OAAO,IAAA;IACP,IAAI,IAAA;IACJ,MAAM,IAAA;IACN,OAAO,IAAA;IACP,KAAK,IAAA;CACN;AAED,oBAAY,iBAAiB;IAC3B,IAAI,IAAA;IACJ,OAAO,IAAA;IACP,IAAI,IAAA;IACJ,MAAM,IAAA;IACN,OAAO,IAAA;IACP,KAAK,IAAA;CACN;AAED,MAAM,MAAM,qBAAqB,GAAG;IAClC,MAAM,EAAE,aAAa,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,yBAAyB,GAAG;IACtC,MAAM,EAAE,iBAAiB,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG;IACpC,UAAU,EAAE,OAAO,CAAC;CACrB,CAAC;AAEF;;;GAGG;AAEH,MAAM,WAAW,yBAAyB;IACxC,IAAI,EAAE,gCAAgC,CAAC;IACvC,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,0BAA0B;IACzC,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,GAAG,CAAC;IACV,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,wBAAwB;IACvC,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,yBAAyB;IACxC,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,iBAAiB;IAChC,UAAU,EAAE,OAAO,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;CAClB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"onboard.js","sourceRoot":"","sources":["../../src/types/onboard.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"onboard.js","sourceRoot":"","sources":["../../src/types/onboard.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,aAOX;AAPD,WAAY,aAAa;IACvB,iDAAI,CAAA;IACJ,uDAAO,CAAA;IACP,iDAAI,CAAA;IACJ,qDAAM,CAAA;IACN,uDAAO,CAAA;IACP,mDAAK,CAAA;AACP,CAAC,EAPW,aAAa,KAAb,aAAa,QAOxB;AAED,MAAM,CAAN,IAAY,iBAOX;AAPD,WAAY,iBAAiB;IAC3B,yDAAI,CAAA;IACJ,+DAAO,CAAA;IACP,yDAAI,CAAA;IACJ,6DAAM,CAAA;IACN,+DAAO,CAAA;IACP,2DAAK,CAAA;AACP,CAAC,EAPW,iBAAiB,KAAjB,iBAAiB,QAO5B"}
|
package/lib-es/types/signer.d.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
export type CantonAddress = {
|
|
2
2
|
publicKey: string;
|
|
3
3
|
address: string;
|
|
4
|
-
path: string;
|
|
5
4
|
};
|
|
6
5
|
export type CantonSignature = string;
|
|
7
6
|
export interface CantonSigner {
|
|
8
|
-
getAddress(path: string
|
|
7
|
+
getAddress(path: string): Promise<CantonAddress>;
|
|
9
8
|
signTransaction(path: string, rawTx: string): Promise<CantonSignature>;
|
|
10
9
|
}
|
|
11
10
|
//# sourceMappingURL=signer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signer.d.ts","sourceRoot":"","sources":["../../src/types/signer.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,aAAa,GAAG;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"signer.d.ts","sourceRoot":"","sources":["../../src/types/signer.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,aAAa,GAAG;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG,MAAM,CAAC;AAErC,MAAM,WAAW,YAAY;IAC3B,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;IACjD,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;CACxE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ledgerhq/coin-canton",
|
|
3
|
-
"version": "0.5.0
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Canton coin integration",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Ledger",
|
|
@@ -101,13 +101,13 @@
|
|
|
101
101
|
"bignumber.js": "^9.1.2",
|
|
102
102
|
"invariant": "^2.2.4",
|
|
103
103
|
"rxjs": "^7.8.1",
|
|
104
|
-
"@ledgerhq/coin-framework": "^6.4.0
|
|
105
|
-
"@ledgerhq/cryptoassets": "^13.28.0
|
|
104
|
+
"@ledgerhq/coin-framework": "^6.4.0",
|
|
105
|
+
"@ledgerhq/cryptoassets": "^13.28.0",
|
|
106
106
|
"@ledgerhq/devices": "8.5.1",
|
|
107
107
|
"@ledgerhq/errors": "^6.25.0",
|
|
108
|
-
"@ledgerhq/live-env": "^2.16.0
|
|
109
|
-
"@ledgerhq/live-network": "^2.0.17
|
|
110
|
-
"@ledgerhq/types-live": "^6.84.0
|
|
108
|
+
"@ledgerhq/live-env": "^2.16.0",
|
|
109
|
+
"@ledgerhq/live-network": "^2.0.17",
|
|
110
|
+
"@ledgerhq/types-live": "^6.84.0"
|
|
111
111
|
},
|
|
112
112
|
"devDependencies": {
|
|
113
113
|
"@types/invariant": "^2.2.37",
|
|
@@ -117,7 +117,7 @@
|
|
|
117
117
|
"jest": "^29.7.0",
|
|
118
118
|
"ts-jest": "^29.1.1",
|
|
119
119
|
"typescript": "^5.4.5",
|
|
120
|
-
"@ledgerhq/types-cryptoassets": "^7.
|
|
120
|
+
"@ledgerhq/types-cryptoassets": "^7.26.0",
|
|
121
121
|
"@ledgerhq/disable-network-setup": "^0.0.0"
|
|
122
122
|
},
|
|
123
123
|
"scripts": {
|
|
@@ -10,7 +10,8 @@ describe("devnet", () => {
|
|
|
10
10
|
networkType: "devnet",
|
|
11
11
|
gatewayUrl: "https://canton-gateway.api.live.ledger-test.com",
|
|
12
12
|
useGateway: true,
|
|
13
|
-
nativeInstrumentId:
|
|
13
|
+
nativeInstrumentId:
|
|
14
|
+
"6e9fc50fb94e56751b49f09ba2dc84da53a9d7cff08115ebb4f6b7a12d0c990c:Splice.Amulet:Amulet",
|
|
14
15
|
});
|
|
15
16
|
});
|
|
16
17
|
|
|
@@ -19,13 +20,9 @@ describe("devnet", () => {
|
|
|
19
20
|
const balance = await api.getBalance(
|
|
20
21
|
"party-4f2e1485107adf5f::122027c6dbbbdbffe0fa3122ae05175f3b9328e879e9ce96b670354deb64a45683c1",
|
|
21
22
|
);
|
|
22
|
-
expect(balance.length).toBeGreaterThanOrEqual(
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
if (nativeBalance) {
|
|
26
|
-
expect(nativeBalance.value).toBeGreaterThanOrEqual(BigInt(0));
|
|
27
|
-
}
|
|
28
|
-
}
|
|
23
|
+
expect(balance.length).toBeGreaterThanOrEqual(1);
|
|
24
|
+
const nativeBalance = balance.find(b => b.asset.type === "native");
|
|
25
|
+
expect(nativeBalance?.value).toBeGreaterThanOrEqual(0);
|
|
29
26
|
});
|
|
30
27
|
});
|
|
31
28
|
});
|
package/src/api/index.ts
CHANGED
|
@@ -2,13 +2,13 @@ import {
|
|
|
2
2
|
AlpacaApi,
|
|
3
3
|
Block,
|
|
4
4
|
BlockInfo,
|
|
5
|
+
CraftedTransaction,
|
|
5
6
|
Cursor,
|
|
6
7
|
FeeEstimation,
|
|
7
8
|
Page,
|
|
8
9
|
Reward,
|
|
9
10
|
Stake,
|
|
10
11
|
TransactionIntent,
|
|
11
|
-
CraftedTransaction,
|
|
12
12
|
} from "@ledgerhq/coin-framework/api/index";
|
|
13
13
|
import coinConfig, { type CantonConfig } from "../config";
|
|
14
14
|
import {
|
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
craftTransaction,
|
|
18
18
|
estimateFees,
|
|
19
19
|
getBalance,
|
|
20
|
+
getNextValidSequence,
|
|
20
21
|
lastBlock,
|
|
21
22
|
listOperations,
|
|
22
23
|
} from "../common-logic";
|
|
@@ -28,8 +29,8 @@ export function createApi(config: CantonConfig): AlpacaApi {
|
|
|
28
29
|
return {
|
|
29
30
|
broadcast,
|
|
30
31
|
combine,
|
|
31
|
-
craftTransaction: craft
|
|
32
|
-
estimateFees: estimate
|
|
32
|
+
craftTransaction: craft,
|
|
33
|
+
estimateFees: estimate,
|
|
33
34
|
getBalance,
|
|
34
35
|
lastBlock,
|
|
35
36
|
listOperations,
|
|
@@ -48,36 +49,28 @@ export function createApi(config: CantonConfig): AlpacaApi {
|
|
|
48
49
|
};
|
|
49
50
|
}
|
|
50
51
|
|
|
51
|
-
|
|
52
|
-
(
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
);
|
|
63
|
-
|
|
64
|
-
return { transaction: tx.serializedTransaction };
|
|
65
|
-
};
|
|
52
|
+
async function craft(transactionIntent: TransactionIntent): Promise<CraftedTransaction> {
|
|
53
|
+
const nextSequenceNumber = await getNextValidSequence(transactionIntent.sender);
|
|
54
|
+
const tx = await craftTransaction(
|
|
55
|
+
{ address: transactionIntent.sender, nextSequenceNumber },
|
|
56
|
+
{
|
|
57
|
+
recipient: transactionIntent.recipient,
|
|
58
|
+
amount: new BigNumber(transactionIntent.amount.toString()),
|
|
59
|
+
},
|
|
60
|
+
);
|
|
61
|
+
return { transaction: tx.serializedTransaction };
|
|
62
|
+
}
|
|
66
63
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
tokenId,
|
|
76
|
-
expireInSeconds: 24 * 60 * 60,
|
|
77
|
-
},
|
|
78
|
-
);
|
|
64
|
+
async function estimate(transactionIntent: TransactionIntent): Promise<FeeEstimation> {
|
|
65
|
+
const { serializedTransaction } = await craftTransaction(
|
|
66
|
+
{ address: transactionIntent.sender },
|
|
67
|
+
{
|
|
68
|
+
recipient: transactionIntent.recipient,
|
|
69
|
+
amount: new BigNumber(transactionIntent.amount.toString()),
|
|
70
|
+
},
|
|
71
|
+
);
|
|
79
72
|
|
|
80
|
-
|
|
73
|
+
const value = await estimateFees(serializedTransaction);
|
|
81
74
|
|
|
82
|
-
|
|
83
|
-
|
|
75
|
+
return { value };
|
|
76
|
+
}
|
package/src/bridge/broadcast.ts
CHANGED
|
@@ -3,8 +3,9 @@ import { patchOperationWithHash } from "@ledgerhq/coin-framework/operation";
|
|
|
3
3
|
import { broadcast as broadcastLogic } from "../common-logic";
|
|
4
4
|
import { Transaction } from "../types";
|
|
5
5
|
|
|
6
|
-
export const broadcast: AccountBridge<Transaction>["broadcast"] = async ({
|
|
7
|
-
|
|
6
|
+
export const broadcast: AccountBridge<Transaction>["broadcast"] = async ({
|
|
7
|
+
signedOperation: { signature, operation },
|
|
8
|
+
}) => {
|
|
8
9
|
const hash = await broadcastLogic(signature);
|
|
9
10
|
return patchOperationWithHash(operation, hash);
|
|
10
11
|
};
|
package/src/bridge/index.ts
CHANGED
|
@@ -21,7 +21,6 @@ import { buildSignOperation } from "./signOperation";
|
|
|
21
21
|
import { getAccountShape } from "./sync";
|
|
22
22
|
import { updateTransaction } from "./updateTransaction";
|
|
23
23
|
import { buildOnboardAccount, buildAuthorizePreapproval } from "./onboard";
|
|
24
|
-
import { assignFromAccountRaw, assignToAccountRaw } from "./serialization";
|
|
25
24
|
|
|
26
25
|
export function createBridges(
|
|
27
26
|
signerContext: SignerContext<CantonSigner>,
|
|
@@ -63,8 +62,6 @@ export function createBridges(
|
|
|
63
62
|
sync,
|
|
64
63
|
receive,
|
|
65
64
|
signOperation,
|
|
66
|
-
assignToAccountRaw,
|
|
67
|
-
assignFromAccountRaw,
|
|
68
65
|
getSerializedAddressParameters,
|
|
69
66
|
};
|
|
70
67
|
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
} from "../types/onboard";
|
|
12
12
|
import coinConfig from "../config";
|
|
13
13
|
|
|
14
|
-
describe("onboard
|
|
14
|
+
describe("onboard integration tests", () => {
|
|
15
15
|
const mockDeviceId = "test-device-id";
|
|
16
16
|
const mockDerivationPath = "44'/6767'/0'/0'/0'";
|
|
17
17
|
|
|
@@ -90,7 +90,7 @@ describe("onboard (devnet)", () => {
|
|
|
90
90
|
const result = await isAccountOnboarded(keyPair.publicKeyHex);
|
|
91
91
|
|
|
92
92
|
// THEN
|
|
93
|
-
expect(result).
|
|
93
|
+
expect(result).toBe(false);
|
|
94
94
|
}, 15000);
|
|
95
95
|
|
|
96
96
|
it("should handle errors gracefully when checking non-existent party", async () => {
|
|
@@ -101,7 +101,7 @@ describe("onboard (devnet)", () => {
|
|
|
101
101
|
const result = await isAccountOnboarded(keyPair.publicKeyHex);
|
|
102
102
|
|
|
103
103
|
// THEN
|
|
104
|
-
expect(result).
|
|
104
|
+
expect(result).toBe(false);
|
|
105
105
|
}, 15000);
|
|
106
106
|
});
|
|
107
107
|
|
package/src/bridge/onboard.ts
CHANGED
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
import { Observable } from "rxjs";
|
|
2
2
|
import { SignerContext } from "@ledgerhq/coin-framework/signer";
|
|
3
|
-
import {
|
|
4
|
-
import { getDerivationModesForCurrency } from "@ledgerhq/coin-framework/derivation";
|
|
5
|
-
import { getCryptoCurrencyById } from "@ledgerhq/cryptoassets/currencies";
|
|
6
|
-
import { getAccountShape } from "./sync";
|
|
7
|
-
import { CantonAccount, CantonSigner } from "../types";
|
|
8
|
-
import type { Account } from "@ledgerhq/types-live";
|
|
3
|
+
import { CantonSigner } from "../types/signer";
|
|
9
4
|
import {
|
|
10
5
|
prepareOnboarding,
|
|
11
6
|
submitOnboarding,
|
|
@@ -24,9 +19,8 @@ import {
|
|
|
24
19
|
CantonPreApprovalResult,
|
|
25
20
|
PrepareTransactionResponse,
|
|
26
21
|
} from "../types/onboard";
|
|
27
|
-
import resolver from "../signer";
|
|
28
22
|
|
|
29
|
-
async function
|
|
23
|
+
async function getKeypair(
|
|
30
24
|
signerContext: SignerContext<CantonSigner>,
|
|
31
25
|
deviceId: string,
|
|
32
26
|
derivationPath: string,
|
|
@@ -37,23 +31,20 @@ async function _getKeypair(
|
|
|
37
31
|
});
|
|
38
32
|
}
|
|
39
33
|
|
|
40
|
-
const currency = getCryptoCurrencyById("canton_network");
|
|
41
|
-
const derivationMode = getDerivationModesForCurrency(currency)[0];
|
|
42
|
-
|
|
43
34
|
export const isAccountOnboarded = async (
|
|
44
35
|
publicKey: string,
|
|
45
|
-
): Promise<
|
|
36
|
+
): Promise<false | { party_id: string }> => {
|
|
46
37
|
try {
|
|
47
38
|
const { party_id } = await getPartyByPubKey(publicKey);
|
|
48
39
|
|
|
49
40
|
if (party_id) {
|
|
50
|
-
return {
|
|
41
|
+
return { party_id };
|
|
51
42
|
} else {
|
|
52
|
-
return
|
|
43
|
+
return false;
|
|
53
44
|
}
|
|
54
45
|
} catch (err) {
|
|
55
46
|
log("[isAccountOnboarded] Error checking party status (likely not onboarded):", err);
|
|
56
|
-
return
|
|
47
|
+
return false;
|
|
57
48
|
}
|
|
58
49
|
};
|
|
59
50
|
|
|
@@ -68,29 +59,22 @@ export const buildOnboardAccount =
|
|
|
68
59
|
observer.next({
|
|
69
60
|
status: OnboardStatus.INIT,
|
|
70
61
|
});
|
|
71
|
-
const
|
|
72
|
-
const { address, publicKey } = await getAddress(deviceId, {
|
|
73
|
-
path: derivationPath,
|
|
74
|
-
currency,
|
|
75
|
-
derivationMode: derivationMode || "",
|
|
76
|
-
});
|
|
62
|
+
const keypair = await getKeypair(signerContext, deviceId, derivationPath);
|
|
77
63
|
|
|
78
64
|
observer.next({
|
|
79
65
|
status: OnboardStatus.PREPARE,
|
|
80
66
|
});
|
|
81
67
|
|
|
82
|
-
const
|
|
83
|
-
if (
|
|
84
|
-
const account = await createAccount({ address, derivationPath, partyId });
|
|
68
|
+
const isOnboardedResult = await isAccountOnboarded(keypair.publicKey);
|
|
69
|
+
if (isOnboardedResult && isOnboardedResult.party_id) {
|
|
85
70
|
observer.next({
|
|
86
|
-
partyId,
|
|
87
|
-
account,
|
|
71
|
+
partyId: isOnboardedResult.party_id,
|
|
88
72
|
});
|
|
89
73
|
observer.complete();
|
|
90
74
|
return;
|
|
91
75
|
}
|
|
92
76
|
|
|
93
|
-
const preparedTransaction = await prepareOnboarding(publicKey, "ed25519");
|
|
77
|
+
const preparedTransaction = await prepareOnboarding(keypair.publicKey, "ed25519");
|
|
94
78
|
|
|
95
79
|
observer.next({
|
|
96
80
|
status: OnboardStatus.SIGN,
|
|
@@ -105,39 +89,26 @@ export const buildOnboardAccount =
|
|
|
105
89
|
});
|
|
106
90
|
|
|
107
91
|
const result = await submitOnboarding(
|
|
108
|
-
{ public_key: publicKey, public_key_type: "ed25519" },
|
|
92
|
+
{ public_key: keypair.publicKey, public_key_type: "ed25519" },
|
|
109
93
|
preparedTransaction,
|
|
110
94
|
signature,
|
|
111
|
-
).catch(
|
|
95
|
+
).catch(err => {
|
|
112
96
|
if (err.type === "PARTY_ALREADY_EXISTS") {
|
|
113
|
-
const account = await createAccount({
|
|
114
|
-
address,
|
|
115
|
-
derivationPath,
|
|
116
|
-
partyId: preparedTransaction.party_id,
|
|
117
|
-
});
|
|
118
97
|
observer.next({
|
|
119
98
|
partyId: preparedTransaction.party_id,
|
|
120
|
-
account,
|
|
121
99
|
});
|
|
122
100
|
return observer.complete();
|
|
123
101
|
}
|
|
124
102
|
throw err;
|
|
125
103
|
});
|
|
126
104
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
partyId: result.party.party_id,
|
|
135
|
-
});
|
|
136
|
-
observer.next({
|
|
137
|
-
partyId: result.party.party_id,
|
|
138
|
-
account,
|
|
139
|
-
});
|
|
140
|
-
}
|
|
105
|
+
observer.next({
|
|
106
|
+
status: OnboardStatus.SUCCESS,
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
observer.next({
|
|
110
|
+
partyId: result?.party?.party_id || "unknown",
|
|
111
|
+
});
|
|
141
112
|
|
|
142
113
|
observer.complete();
|
|
143
114
|
}
|
|
@@ -193,35 +164,38 @@ export const buildAuthorizePreapproval =
|
|
|
193
164
|
isApproved,
|
|
194
165
|
});
|
|
195
166
|
|
|
167
|
+
// TODO: remove after demo
|
|
196
168
|
const handleTapRequest = async () => {
|
|
197
169
|
try {
|
|
170
|
+
observer.next({
|
|
171
|
+
status: PreApprovalStatus.PREPARE,
|
|
172
|
+
});
|
|
173
|
+
|
|
198
174
|
const { serialized, hash } = await prepareTapRequest({
|
|
199
175
|
partyId,
|
|
200
176
|
});
|
|
201
177
|
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
});
|
|
224
|
-
}
|
|
178
|
+
observer.next({
|
|
179
|
+
status: PreApprovalStatus.SIGN,
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
const signature = await signerContext(deviceId, signer =>
|
|
183
|
+
signer.signTransaction(derivationPath, hash),
|
|
184
|
+
);
|
|
185
|
+
|
|
186
|
+
observer.next({
|
|
187
|
+
status: PreApprovalStatus.SUBMIT,
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
await submitTapRequest({
|
|
191
|
+
partyId,
|
|
192
|
+
serialized,
|
|
193
|
+
signature,
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
observer.next({
|
|
197
|
+
status: PreApprovalStatus.SUCCESS,
|
|
198
|
+
});
|
|
225
199
|
} catch (err) {
|
|
226
200
|
// Tap request failure should not break the pre-approval flow
|
|
227
201
|
}
|
|
@@ -240,54 +214,7 @@ export const buildAuthorizePreapproval =
|
|
|
240
214
|
);
|
|
241
215
|
});
|
|
242
216
|
|
|
243
|
-
const
|
|
244
|
-
address,
|
|
245
|
-
partyId,
|
|
246
|
-
derivationPath,
|
|
247
|
-
index = 0,
|
|
248
|
-
}: {
|
|
249
|
-
address: string;
|
|
250
|
-
derivationPath: string;
|
|
251
|
-
partyId: string;
|
|
252
|
-
index?: number;
|
|
253
|
-
}): Promise<Partial<Account>> => {
|
|
254
|
-
const accountShape = await getAccountShape(
|
|
255
|
-
{
|
|
256
|
-
address,
|
|
257
|
-
currency,
|
|
258
|
-
derivationMode,
|
|
259
|
-
derivationPath,
|
|
260
|
-
index,
|
|
261
|
-
rest: {
|
|
262
|
-
cantonResources: {
|
|
263
|
-
partyId,
|
|
264
|
-
},
|
|
265
|
-
},
|
|
266
|
-
},
|
|
267
|
-
{ paginationConfig: {} },
|
|
268
|
-
);
|
|
269
|
-
|
|
270
|
-
const account: Partial<CantonAccount> = {
|
|
271
|
-
...accountShape,
|
|
272
|
-
type: "Account",
|
|
273
|
-
xpub: partyId.replace(/:/g, "_"),
|
|
274
|
-
index,
|
|
275
|
-
// operations: [],
|
|
276
|
-
currency,
|
|
277
|
-
derivationMode,
|
|
278
|
-
lastSyncDate: new Date(),
|
|
279
|
-
pendingOperations: [],
|
|
280
|
-
seedIdentifier: address,
|
|
281
|
-
balanceHistoryCache: emptyHistoryCache,
|
|
282
|
-
cantonResources: {
|
|
283
|
-
partyId,
|
|
284
|
-
},
|
|
285
|
-
};
|
|
286
|
-
|
|
287
|
-
return account;
|
|
288
|
-
};
|
|
289
|
-
|
|
290
|
-
const log = (message: string, ...rest: unknown[]) => {
|
|
217
|
+
const log = (message: string, ...rest: any[]) => {
|
|
291
218
|
// eslint-disable-next-line no-console
|
|
292
219
|
console.log(message, ...rest);
|
|
293
220
|
};
|
|
@@ -1,16 +1,25 @@
|
|
|
1
1
|
import { AccountBridge } from "@ledgerhq/types-live";
|
|
2
2
|
import { Transaction } from "../types";
|
|
3
|
-
import { estimateFees } from "../common-logic";
|
|
3
|
+
import { craftTransaction, estimateFees } from "../common-logic";
|
|
4
|
+
import { getNextSequence } from "../network/node";
|
|
4
5
|
import BigNumber from "bignumber.js";
|
|
5
|
-
import { updateTransaction } from "./updateTransaction";
|
|
6
6
|
|
|
7
7
|
export const prepareTransaction: AccountBridge<Transaction>["prepareTransaction"] = async (
|
|
8
8
|
account,
|
|
9
9
|
transaction,
|
|
10
10
|
) => {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
const seq = await getNextSequence(account.freshAddress);
|
|
12
|
+
|
|
13
|
+
const craftedTransaction = await craftTransaction(
|
|
14
|
+
{ address: account.freshAddress, nextSequenceNumber: seq },
|
|
15
|
+
{ amount: transaction.amount, recipient: transaction.recipient },
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
const fee = await estimateFees(craftedTransaction.serializedTransaction);
|
|
19
|
+
|
|
20
|
+
if (transaction.fee !== new BigNumber(fee.toString())) {
|
|
21
|
+
return { ...transaction, fee: new BigNumber(fee.toString()) };
|
|
14
22
|
}
|
|
15
|
-
|
|
23
|
+
|
|
24
|
+
return transaction;
|
|
16
25
|
};
|
|
@@ -3,8 +3,8 @@ import { FeeNotLoaded } from "@ledgerhq/errors";
|
|
|
3
3
|
import { AccountBridge, Operation } from "@ledgerhq/types-live";
|
|
4
4
|
import { SignerContext } from "@ledgerhq/coin-framework/signer";
|
|
5
5
|
import { encodeOperationId } from "@ledgerhq/coin-framework/operation";
|
|
6
|
-
import { combine, craftTransaction } from "../common-logic";
|
|
7
|
-
import { Transaction, CantonSigner } from "../types";
|
|
6
|
+
import { combine, craftTransaction, getNextValidSequence } from "../common-logic";
|
|
7
|
+
import { Transaction, CantonSigner, BoilerplateNativeTransaction } from "../types";
|
|
8
8
|
|
|
9
9
|
export const buildSignOperation =
|
|
10
10
|
(signerContext: SignerContext<CantonSigner>): AccountBridge<Transaction>["signOperation"] =>
|
|
@@ -20,24 +20,30 @@ export const buildSignOperation =
|
|
|
20
20
|
type: "device-signature-requested",
|
|
21
21
|
});
|
|
22
22
|
|
|
23
|
+
const nextSequenceNumber = await getNextValidSequence(account.freshAddress);
|
|
24
|
+
|
|
23
25
|
const signature = await signerContext(deviceId, async signer => {
|
|
24
26
|
const { freshAddressPath: derivationPath } = account;
|
|
25
|
-
const
|
|
27
|
+
const { publicKey } = await signer.getAddress(derivationPath);
|
|
26
28
|
|
|
27
|
-
const {
|
|
29
|
+
const { nativeTransaction, serializedTransaction } = await craftTransaction(
|
|
28
30
|
{
|
|
29
|
-
address:
|
|
31
|
+
address: account.freshAddress,
|
|
32
|
+
publicKey,
|
|
30
33
|
},
|
|
31
34
|
{
|
|
32
35
|
recipient: transaction.recipient,
|
|
33
36
|
amount: transaction.amount,
|
|
34
|
-
|
|
35
|
-
tokenId: "Amulet",
|
|
37
|
+
fee: fee,
|
|
36
38
|
},
|
|
37
39
|
);
|
|
38
|
-
const transactionSignature = await signer.signTransaction(derivationPath, hash);
|
|
39
40
|
|
|
40
|
-
|
|
41
|
+
const transactionSignature = await signer.signTransaction(
|
|
42
|
+
derivationPath,
|
|
43
|
+
serializedTransaction,
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
return combine(serializedTransaction, transactionSignature);
|
|
41
47
|
});
|
|
42
48
|
|
|
43
49
|
o.next({
|
|
@@ -58,6 +64,7 @@ export const buildSignOperation =
|
|
|
58
64
|
senders: [account.freshAddress],
|
|
59
65
|
recipients: [transaction.recipient],
|
|
60
66
|
date: new Date(),
|
|
67
|
+
transactionSequenceNumber: nextSequenceNumber,
|
|
61
68
|
extra: {},
|
|
62
69
|
};
|
|
63
70
|
|