@ledgerhq/coin-canton 0.5.0-nightly.1 → 0.5.0-nightly.3

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.
Files changed (199) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/.unimportedrc.json +12 -4
  3. package/CHANGELOG.md +32 -0
  4. package/lib/api/getBalance.integ.test.js +1 -1
  5. package/lib/api/getBalance.integ.test.js.map +1 -1
  6. package/lib/api/index.d.ts.map +1 -1
  7. package/lib/api/index.js +11 -8
  8. package/lib/api/index.js.map +1 -1
  9. package/lib/bridge/broadcast.d.ts.map +1 -1
  10. package/lib/bridge/broadcast.js +2 -1
  11. package/lib/bridge/broadcast.js.map +1 -1
  12. package/lib/bridge/createTransaction.test.js +1 -1
  13. package/lib/bridge/createTransaction.test.js.map +1 -1
  14. package/lib/bridge/index.d.ts +3 -3
  15. package/lib/bridge/index.d.ts.map +1 -1
  16. package/lib/bridge/index.js +9 -1
  17. package/lib/bridge/index.js.map +1 -1
  18. package/lib/bridge/onboard.d.ts +10 -0
  19. package/lib/bridge/onboard.d.ts.map +1 -0
  20. package/lib/bridge/onboard.integ.test.d.ts +2 -0
  21. package/lib/bridge/onboard.integ.test.d.ts.map +1 -0
  22. package/lib/bridge/onboard.integ.test.js +156 -0
  23. package/lib/bridge/onboard.integ.test.js.map +1 -0
  24. package/lib/bridge/onboard.js +139 -0
  25. package/lib/bridge/onboard.js.map +1 -0
  26. package/lib/bridge/prepareTransaction.d.ts.map +1 -1
  27. package/lib/bridge/prepareTransaction.js +5 -7
  28. package/lib/bridge/prepareTransaction.js.map +1 -1
  29. package/lib/bridge/signOperation.d.ts.map +1 -1
  30. package/lib/bridge/signOperation.js +7 -9
  31. package/lib/bridge/signOperation.js.map +1 -1
  32. package/lib/bridge/sync.d.ts.map +1 -1
  33. package/lib/bridge/sync.integ.test.d.ts +2 -0
  34. package/lib/bridge/sync.integ.test.d.ts.map +1 -0
  35. package/lib/bridge/sync.integ.test.js +175 -0
  36. package/lib/bridge/sync.integ.test.js.map +1 -0
  37. package/lib/bridge/sync.js +40 -36
  38. package/lib/bridge/sync.js.map +1 -1
  39. package/lib/bridge/updateTransaction.d.ts.map +1 -1
  40. package/lib/bridge/updateTransaction.js +0 -4
  41. package/lib/bridge/updateTransaction.js.map +1 -1
  42. package/lib/common-logic/history/listOperations.d.ts.map +1 -1
  43. package/lib/common-logic/history/listOperations.js +19 -31
  44. package/lib/common-logic/history/listOperations.js.map +1 -1
  45. package/lib/common-logic/transaction/broadcast.d.ts.map +1 -1
  46. package/lib/common-logic/transaction/broadcast.js +2 -1
  47. package/lib/common-logic/transaction/broadcast.js.map +1 -1
  48. package/lib/common-logic/transaction/broadcast.test.js +3 -3
  49. package/lib/common-logic/transaction/broadcast.test.js.map +1 -1
  50. package/lib/common-logic/transaction/combine.d.ts +1 -1
  51. package/lib/common-logic/transaction/combine.d.ts.map +1 -1
  52. package/lib/common-logic/transaction/combine.js +2 -3
  53. package/lib/common-logic/transaction/combine.js.map +1 -1
  54. package/lib/common-logic/transaction/combine.test.js +3 -13
  55. package/lib/common-logic/transaction/combine.test.js.map +1 -1
  56. package/lib/common-logic/transaction/craftTransaction.d.ts +5 -3
  57. package/lib/common-logic/transaction/craftTransaction.d.ts.map +1 -1
  58. package/lib/common-logic/transaction/craftTransaction.js +11 -12
  59. package/lib/common-logic/transaction/craftTransaction.js.map +1 -1
  60. package/lib/network/gateway.d.ts +196 -5
  61. package/lib/network/gateway.d.ts.map +1 -1
  62. package/lib/network/gateway.integ.test.js +121 -11
  63. package/lib/network/gateway.integ.test.js.map +1 -1
  64. package/lib/network/gateway.js +99 -21
  65. package/lib/network/gateway.js.map +1 -1
  66. package/lib/network/node.d.ts +2 -2
  67. package/lib/network/node.d.ts.map +1 -1
  68. package/lib/network/node.js.map +1 -1
  69. package/lib/network/types.d.ts +1 -1
  70. package/lib/network/types.d.ts.map +1 -1
  71. package/lib/signer/getAddress.d.ts.map +1 -1
  72. package/lib/signer/getAddress.js +2 -2
  73. package/lib/signer/getAddress.js.map +1 -1
  74. package/lib/test/cantonTestUtils.d.ts +33 -0
  75. package/lib/test/cantonTestUtils.d.ts.map +1 -0
  76. package/lib/test/cantonTestUtils.js +159 -0
  77. package/lib/test/cantonTestUtils.js.map +1 -0
  78. package/lib/types/bridge.d.ts +7 -1
  79. package/lib/types/bridge.d.ts.map +1 -1
  80. package/lib/types/index.d.ts +1 -10
  81. package/lib/types/index.d.ts.map +1 -1
  82. package/lib/types/index.js +1 -0
  83. package/lib/types/index.js.map +1 -1
  84. package/lib/types/onboard.d.ts +55 -0
  85. package/lib/types/onboard.d.ts.map +1 -0
  86. package/lib/types/onboard.js +22 -0
  87. package/lib/types/onboard.js.map +1 -0
  88. package/lib-es/api/getBalance.integ.test.js +1 -1
  89. package/lib-es/api/getBalance.integ.test.js.map +1 -1
  90. package/lib-es/api/index.d.ts.map +1 -1
  91. package/lib-es/api/index.js +12 -9
  92. package/lib-es/api/index.js.map +1 -1
  93. package/lib-es/bridge/broadcast.d.ts.map +1 -1
  94. package/lib-es/bridge/broadcast.js +2 -1
  95. package/lib-es/bridge/broadcast.js.map +1 -1
  96. package/lib-es/bridge/createTransaction.test.js +1 -1
  97. package/lib-es/bridge/createTransaction.test.js.map +1 -1
  98. package/lib-es/bridge/index.d.ts +3 -3
  99. package/lib-es/bridge/index.d.ts.map +1 -1
  100. package/lib-es/bridge/index.js +9 -1
  101. package/lib-es/bridge/index.js.map +1 -1
  102. package/lib-es/bridge/onboard.d.ts +10 -0
  103. package/lib-es/bridge/onboard.d.ts.map +1 -0
  104. package/lib-es/bridge/onboard.integ.test.d.ts +2 -0
  105. package/lib-es/bridge/onboard.integ.test.d.ts.map +1 -0
  106. package/lib-es/bridge/onboard.integ.test.js +151 -0
  107. package/lib-es/bridge/onboard.integ.test.js.map +1 -0
  108. package/lib-es/bridge/onboard.js +133 -0
  109. package/lib-es/bridge/onboard.js.map +1 -0
  110. package/lib-es/bridge/prepareTransaction.d.ts.map +1 -1
  111. package/lib-es/bridge/prepareTransaction.js +6 -8
  112. package/lib-es/bridge/prepareTransaction.js.map +1 -1
  113. package/lib-es/bridge/signOperation.d.ts.map +1 -1
  114. package/lib-es/bridge/signOperation.js +8 -10
  115. package/lib-es/bridge/signOperation.js.map +1 -1
  116. package/lib-es/bridge/sync.d.ts.map +1 -1
  117. package/lib-es/bridge/sync.integ.test.d.ts +2 -0
  118. package/lib-es/bridge/sync.integ.test.d.ts.map +1 -0
  119. package/lib-es/bridge/sync.integ.test.js +137 -0
  120. package/lib-es/bridge/sync.integ.test.js.map +1 -0
  121. package/lib-es/bridge/sync.js +39 -35
  122. package/lib-es/bridge/sync.js.map +1 -1
  123. package/lib-es/bridge/updateTransaction.d.ts.map +1 -1
  124. package/lib-es/bridge/updateTransaction.js +0 -4
  125. package/lib-es/bridge/updateTransaction.js.map +1 -1
  126. package/lib-es/common-logic/history/listOperations.d.ts.map +1 -1
  127. package/lib-es/common-logic/history/listOperations.js +20 -29
  128. package/lib-es/common-logic/history/listOperations.js.map +1 -1
  129. package/lib-es/common-logic/transaction/broadcast.d.ts.map +1 -1
  130. package/lib-es/common-logic/transaction/broadcast.js +2 -1
  131. package/lib-es/common-logic/transaction/broadcast.js.map +1 -1
  132. package/lib-es/common-logic/transaction/broadcast.test.js +3 -3
  133. package/lib-es/common-logic/transaction/broadcast.test.js.map +1 -1
  134. package/lib-es/common-logic/transaction/combine.d.ts +1 -1
  135. package/lib-es/common-logic/transaction/combine.d.ts.map +1 -1
  136. package/lib-es/common-logic/transaction/combine.js +2 -3
  137. package/lib-es/common-logic/transaction/combine.js.map +1 -1
  138. package/lib-es/common-logic/transaction/combine.test.js +3 -13
  139. package/lib-es/common-logic/transaction/combine.test.js.map +1 -1
  140. package/lib-es/common-logic/transaction/craftTransaction.d.ts +5 -3
  141. package/lib-es/common-logic/transaction/craftTransaction.d.ts.map +1 -1
  142. package/lib-es/common-logic/transaction/craftTransaction.js +11 -12
  143. package/lib-es/common-logic/transaction/craftTransaction.js.map +1 -1
  144. package/lib-es/network/gateway.d.ts +196 -5
  145. package/lib-es/network/gateway.d.ts.map +1 -1
  146. package/lib-es/network/gateway.integ.test.js +122 -12
  147. package/lib-es/network/gateway.integ.test.js.map +1 -1
  148. package/lib-es/network/gateway.js +93 -20
  149. package/lib-es/network/gateway.js.map +1 -1
  150. package/lib-es/network/node.d.ts +2 -2
  151. package/lib-es/network/node.d.ts.map +1 -1
  152. package/lib-es/network/node.js.map +1 -1
  153. package/lib-es/network/types.d.ts +1 -1
  154. package/lib-es/network/types.d.ts.map +1 -1
  155. package/lib-es/signer/getAddress.d.ts.map +1 -1
  156. package/lib-es/signer/getAddress.js +2 -2
  157. package/lib-es/signer/getAddress.js.map +1 -1
  158. package/lib-es/test/cantonTestUtils.d.ts +33 -0
  159. package/lib-es/test/cantonTestUtils.d.ts.map +1 -0
  160. package/lib-es/test/cantonTestUtils.js +151 -0
  161. package/lib-es/test/cantonTestUtils.js.map +1 -0
  162. package/lib-es/types/bridge.d.ts +7 -1
  163. package/lib-es/types/bridge.d.ts.map +1 -1
  164. package/lib-es/types/index.d.ts +1 -10
  165. package/lib-es/types/index.d.ts.map +1 -1
  166. package/lib-es/types/index.js +1 -0
  167. package/lib-es/types/index.js.map +1 -1
  168. package/lib-es/types/onboard.d.ts +55 -0
  169. package/lib-es/types/onboard.d.ts.map +1 -0
  170. package/lib-es/types/onboard.js +19 -0
  171. package/lib-es/types/onboard.js.map +1 -0
  172. package/package.json +7 -7
  173. package/src/api/getBalance.integ.test.ts +1 -2
  174. package/src/api/index.ts +33 -26
  175. package/src/bridge/broadcast.ts +2 -3
  176. package/src/bridge/createTransaction.test.ts +1 -1
  177. package/src/bridge/index.ts +14 -4
  178. package/src/bridge/onboard.integ.test.ts +219 -0
  179. package/src/bridge/onboard.ts +220 -0
  180. package/src/bridge/prepareTransaction.ts +6 -15
  181. package/src/bridge/signOperation.ts +9 -16
  182. package/src/bridge/sync.integ.test.ts +180 -0
  183. package/src/bridge/sync.ts +61 -49
  184. package/src/bridge/updateTransaction.ts +0 -5
  185. package/src/common-logic/history/listOperations.ts +20 -31
  186. package/src/common-logic/transaction/broadcast.test.ts +3 -3
  187. package/src/common-logic/transaction/broadcast.ts +2 -1
  188. package/src/common-logic/transaction/combine.test.ts +3 -13
  189. package/src/common-logic/transaction/combine.ts +2 -4
  190. package/src/common-logic/transaction/craftTransaction.ts +15 -17
  191. package/src/network/gateway.integ.test.ts +156 -17
  192. package/src/network/gateway.ts +337 -30
  193. package/src/network/node.ts +3 -3
  194. package/src/network/types.ts +1 -1
  195. package/src/signer/getAddress.ts +3 -5
  196. package/src/test/cantonTestUtils.ts +181 -0
  197. package/src/types/bridge.ts +20 -0
  198. package/src/types/index.ts +1 -11
  199. package/src/types/onboard.ts +65 -0
@@ -3,7 +3,7 @@ import network from "@ledgerhq/live-network";
3
3
  import type { LiveNetworkRequest } from "@ledgerhq/live-network/network";
4
4
  import { getEnv } from "@ledgerhq/live-env";
5
5
  import coinConfig from "../config";
6
- import { AccountInfoResponse, SubmitReponse } from "./types";
6
+ import { AccountInfoResponse, SubmitResponse } from "./types";
7
7
  import crypto from "crypto";
8
8
 
9
9
  const getNodeUrl = () => coinConfig.getCoinConfig().nodeUrl || "";
@@ -86,10 +86,10 @@ export const getLedgerEnd = async (): Promise<number> => {
86
86
  return data.offset;
87
87
  };
88
88
 
89
- export const submit = async (signedTx: string): Promise<SubmitReponse> => {
89
+ export const submit = async (signedTx: string): Promise<SubmitResponse> => {
90
90
  // @ts-expect-error: add NODE_BOILERPLATE to libs/env/src/env.ts
91
91
  const url = `${getEnv("NODE_BOILERPLATE")}/submit`;
92
- const { data } = await network<SubmitReponse>({
92
+ const { data } = await network<SubmitResponse>({
93
93
  url,
94
94
  method: "GET",
95
95
  });
@@ -40,7 +40,7 @@ export type AccountInfoResponse = {
40
40
  validated: boolean;
41
41
  } & ResponseStatus;
42
42
 
43
- export type SubmitReponse = {
43
+ export type SubmitResponse = {
44
44
  accepted: boolean;
45
45
  tx_hash: string;
46
46
  };
@@ -1,13 +1,11 @@
1
1
  import { GetAddressOptions } from "@ledgerhq/coin-framework/derivation";
2
2
  import { GetAddressFn } from "@ledgerhq/coin-framework/bridge/getAddressWrapper";
3
3
  import { SignerContext } from "@ledgerhq/coin-framework/signer";
4
- import { CantonAddress, CantonSigner } from "../types";
4
+ import { CantonSigner } from "../types";
5
5
 
6
6
  const getAddress = (signerContext: SignerContext<CantonSigner>): GetAddressFn => {
7
- return async (deviceId: string, { path, verify }: GetAddressOptions) => {
8
- const { address, publicKey } = (await signerContext(deviceId, signer =>
9
- signer.getAddress(path),
10
- )) as CantonAddress;
7
+ return async (deviceId: string, { path }: GetAddressOptions) => {
8
+ const { address, publicKey } = await signerContext(deviceId, signer => signer.getAddress(path));
11
9
 
12
10
  return {
13
11
  path,
@@ -0,0 +1,181 @@
1
+ /**
2
+ * Canton Testing Utilities for Ed25519 Key Generation
3
+ *
4
+ * Provides utilities to generate proper Ed25519 keypairs for testing Canton
5
+ * onboarding without requiring physical Ledger devices.
6
+ */
7
+
8
+ import crypto from "crypto";
9
+
10
+ export interface CantonTestKeyPair {
11
+ publicKeyHex: string; // Ready for Canton Gateway API
12
+ privateKeyHex: string; // ASN.1 DER encoded private key in hex format
13
+ privateKeyPem: string; // PEM format for signing operations
14
+ fingerprint: string; // Canton public key fingerprint (multihash: 1220 + SHA256(publicKey))
15
+ sign: (hashHex: string) => string; // Sign transaction hash
16
+ }
17
+
18
+ /**
19
+ * Generate fresh Ed25519 keypair
20
+ */
21
+ export function generateMockKeyPair(): CantonTestKeyPair {
22
+ const { publicKey, privateKey } = crypto.generateKeyPairSync("ed25519");
23
+
24
+ const publicKeyBuffer = publicKey.export({ type: "spki", format: "der" });
25
+ const rawPublicKey = publicKeyBuffer.slice(-32);
26
+ const publicKeyHex = rawPublicKey.toString("hex");
27
+
28
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
29
+ const privateKeyPem = privateKey.export({ type: "pkcs8", format: "pem" }) as string;
30
+ const privateKeyDer = privateKey.export({ type: "pkcs8", format: "der" });
31
+ const privateKeyHex = privateKeyDer.toString("hex");
32
+
33
+ // Generate fingerprint: Canton computes SHA256(purpose_bytes + public_key_bytes)
34
+ // where purpose_bytes is 4-byte big-endian representation of PURPOSE_PUBLIC_KEY_FINGERPRINT (12)
35
+ const PURPOSE_PUBLIC_KEY_FINGERPRINT = 12;
36
+ const purposeBytes = Buffer.allocUnsafe(4);
37
+ purposeBytes.writeInt32BE(PURPOSE_PUBLIC_KEY_FINGERPRINT, 0);
38
+
39
+ const hash = crypto.createHash("sha256");
40
+ hash.update(purposeBytes);
41
+ hash.update(rawPublicKey);
42
+ const hashedContent = hash.digest();
43
+
44
+ // Multihash encoding: 0x12 (SHA256) + 0x20 (32 bytes) + hash
45
+ const multihashPrefix = Buffer.from([0x12, 0x20]);
46
+ const fingerprintBuffer = Buffer.concat([multihashPrefix, hashedContent]);
47
+ const fingerprint = fingerprintBuffer.toString("hex");
48
+
49
+ return {
50
+ publicKeyHex, // 64-char hex string (no 0x prefix)
51
+ privateKeyHex, // ASN.1 DER encoded private key in hex format
52
+ privateKeyPem, // PEM format string
53
+ fingerprint, // Canton format: multihash prefix + SHA256(public key)
54
+
55
+ /**
56
+ * Sign a transaction hash using proper Ed25519 signature
57
+ */
58
+ sign: (hashHex: string): string => {
59
+ const hashBuffer = Buffer.from(hashHex, "hex");
60
+ const privateKeyObj = crypto.createPrivateKey({
61
+ key: privateKeyPem,
62
+ format: "pem",
63
+ type: "pkcs8",
64
+ });
65
+
66
+ const signature = crypto.sign(null, hashBuffer, privateKeyObj);
67
+ return signature.toString("hex");
68
+ },
69
+ };
70
+ }
71
+
72
+ /**
73
+ * Verify Ed25519 signature against public key and message hash
74
+ */
75
+ export function verifySignature(
76
+ publicKeyHex: string,
77
+ signatureHex: string,
78
+ messageHashHex: string,
79
+ ): { isValid: boolean; error?: string; details: any } {
80
+ try {
81
+ // Clean inputs - remove 0x prefixes if present
82
+ const cleanPublicKey = publicKeyHex.startsWith("0x") ? publicKeyHex.slice(2) : publicKeyHex;
83
+ const cleanSignature = signatureHex.startsWith("0x") ? signatureHex.slice(2) : signatureHex;
84
+ const cleanMessageHash = messageHashHex.startsWith("0x")
85
+ ? messageHashHex.slice(2)
86
+ : messageHashHex;
87
+
88
+ const details: any = {
89
+ publicKeyLength: cleanPublicKey.length,
90
+ signatureLength: cleanSignature.length,
91
+ messageHashLength: cleanMessageHash.length,
92
+ publicKeyBytes: cleanPublicKey.length / 2,
93
+ signatureBytes: cleanSignature.length / 2,
94
+ messageHashBytes: cleanMessageHash.length / 2,
95
+ };
96
+
97
+ // Validate input lengths
98
+ if (cleanPublicKey.length !== 64) {
99
+ return {
100
+ isValid: false,
101
+ error: `Invalid public key length: expected 64 hex chars (32 bytes), got ${cleanPublicKey.length}`,
102
+ details,
103
+ };
104
+ }
105
+
106
+ // Ed25519 signatures should be 64 bytes, but we might receive 65 bytes with recovery ID
107
+ let processedSignature = cleanSignature;
108
+ if (cleanSignature.length === 130) {
109
+ processedSignature = cleanSignature.slice(2, -2);
110
+ details.originalSignatureLength = cleanSignature.length;
111
+ details.processedSignatureLength = processedSignature.length;
112
+ } else if (cleanSignature.length !== 128) {
113
+ return {
114
+ isValid: false,
115
+ error: `Invalid signature length: expected 128 hex chars (64 bytes) or 130 hex chars (65 bytes), got ${cleanSignature.length}`,
116
+ details,
117
+ };
118
+ }
119
+
120
+ // Convert hex to buffers
121
+ const publicKeyBuffer = Buffer.from(cleanPublicKey, "hex");
122
+ const signatureBuffer = Buffer.from(processedSignature, "hex");
123
+ const messageBuffer = Buffer.from(cleanMessageHash, "hex");
124
+
125
+ // Create public key object for verification
126
+ // Ed25519 public keys need to be wrapped in SPKI format for Node.js crypto
127
+ const spkiHeader = Buffer.from([
128
+ 0x30,
129
+ 0x2a, // SEQUENCE, length 42
130
+ 0x30,
131
+ 0x05, // SEQUENCE, length 5
132
+ 0x06,
133
+ 0x03,
134
+ 0x2b,
135
+ 0x65,
136
+ 0x70, // OID for Ed25519
137
+ 0x03,
138
+ 0x21,
139
+ 0x00, // BIT STRING, length 33, no unused bits
140
+ ]);
141
+ const spkiPublicKey = Buffer.concat([spkiHeader, publicKeyBuffer]);
142
+
143
+ const publicKeyObj = crypto.createPublicKey({
144
+ key: spkiPublicKey,
145
+ format: "der",
146
+ type: "spki",
147
+ });
148
+
149
+ // Verify signature
150
+ const isValid = crypto.verify(null, messageBuffer, publicKeyObj, signatureBuffer);
151
+
152
+ return {
153
+ isValid,
154
+ details: {
155
+ ...details,
156
+ processedSignatureLength: processedSignature.length,
157
+ verificationMethod: "Node.js crypto.verify with Ed25519",
158
+ },
159
+ };
160
+ } catch (error) {
161
+ return {
162
+ isValid: false,
163
+ error: `Verification failed: ${error instanceof Error ? error.message : String(error)}`,
164
+ details: { error: String(error) },
165
+ };
166
+ }
167
+ }
168
+
169
+ export function createMockSigner(keyPair: CantonTestKeyPair) {
170
+ return {
171
+ getAddress: async (derivationPath: string) => ({
172
+ address: `canton_test_${keyPair.fingerprint.slice(-8)}`,
173
+ publicKey: keyPair.publicKeyHex,
174
+ }),
175
+
176
+ signTransaction: async (derivationPath: string, hashToSign: string) => {
177
+ const cleanHash = hashToSign.startsWith("0x") ? hashToSign.slice(2) : hashToSign;
178
+ return keyPair.sign(cleanHash);
179
+ },
180
+ };
181
+ }
@@ -1,10 +1,30 @@
1
1
  import type { BigNumber } from "bignumber.js";
2
+ import type { Observable } from "rxjs";
2
3
  import type {
4
+ CurrencyBridge,
3
5
  TransactionCommon,
4
6
  TransactionCommonRaw,
5
7
  TransactionStatusCommon,
6
8
  TransactionStatusCommonRaw,
7
9
  } from "@ledgerhq/types-live";
10
+ import type {
11
+ CantonOnboardProgress,
12
+ CantonOnboardResult,
13
+ CantonPreApprovalProgress,
14
+ CantonPreApprovalResult,
15
+ } from "./onboard";
16
+
17
+ export interface CantonCurrencyBridge extends CurrencyBridge {
18
+ onboardAccount: (
19
+ deviceId: string,
20
+ derivationPath: string,
21
+ ) => Observable<CantonOnboardProgress | CantonOnboardResult>;
22
+ authorizePreapproval: (
23
+ deviceId: string,
24
+ derivationPath: string,
25
+ partyId: string,
26
+ ) => Observable<CantonPreApprovalProgress | CantonPreApprovalResult>;
27
+ }
8
28
 
9
29
  export type NetworkInfo = {
10
30
  family: "canton";
@@ -1,13 +1,3 @@
1
1
  export * from "./bridge";
2
+ export * from "./onboard";
2
3
  export * from "./signer";
3
-
4
- export type BoilerplateNativeTransaction = {
5
- TransactionType: "Payment";
6
- Account: string;
7
- Amount: string;
8
- Destination: string;
9
- Fee: string;
10
- Sequence: number;
11
- SigningPubKey?: string;
12
- TxnSignature?: string;
13
- };
@@ -0,0 +1,65 @@
1
+ export enum OnboardStatus {
2
+ INIT,
3
+ PREPARE,
4
+ SIGN,
5
+ SUBMIT,
6
+ SUCCESS,
7
+ ERROR,
8
+ }
9
+
10
+ export enum PreApprovalStatus {
11
+ INIT,
12
+ PREPARE,
13
+ SIGN,
14
+ SUBMIT,
15
+ SUCCESS,
16
+ ERROR,
17
+ }
18
+
19
+ export type CantonOnboardProgress = {
20
+ status: OnboardStatus;
21
+ };
22
+
23
+ export type CantonOnboardResult = {
24
+ partyId: string;
25
+ };
26
+
27
+ export type CantonPreApprovalProgress = {
28
+ status: PreApprovalStatus;
29
+ };
30
+
31
+ export type CantonPreApprovalResult = {
32
+ isApproved: boolean;
33
+ };
34
+
35
+ /**
36
+ * Types for Canton Gateway Transaction API
37
+ * Based on the API endpoints in canton-gateway
38
+ */
39
+
40
+ export interface PrepareTransactionRequest {
41
+ type: "transfer-pre-approval-proposal";
42
+ receiver: string;
43
+ }
44
+
45
+ export interface PrepareTransactionResponse {
46
+ serialized: string; // Hex-encoded serialized protobuf
47
+ json: any; // JSON representation
48
+ hash: string; // Transaction hash for signing
49
+ }
50
+
51
+ export interface SubmitTransactionRequest {
52
+ serialized: string; // Hex-encoded serialized protobuf
53
+ signature: string; // Hex-encoded signature
54
+ }
55
+
56
+ export interface SubmitTransactionResponse {
57
+ submission_id: string;
58
+ update_id: string;
59
+ }
60
+
61
+ export interface PreApprovalResult {
62
+ isApproved: boolean;
63
+ submissionId: string;
64
+ updateId: string;
65
+ }