@vultisig/core-chain 2.11.0 → 2.12.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/CHANGELOG.md CHANGED
@@ -1,5 +1,26 @@
1
1
  # @vultisig/core-chain
2
2
 
3
+ ## 2.12.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#651](https://github.com/vultisig/vultisig-sdk/pull/651) [`e9c4997`](https://github.com/vultisig/vultisig-sdk/commit/e9c4997bae3a499785295b76dbc956807cc704f5) Thanks [@Ehsan-saradar](https://github.com/Ehsan-saradar)! - Add Sui dApp signing helpers to `@vultisig/core-chain/chains/sui`. Two new
8
+ public modules:
9
+ - `./chains/sui/sign` exports `suiTransactionDataIntent` /
10
+ `suiPersonalMessageIntent` (defensive clones of the 3-byte intent
11
+ prefixes), `getSuiTransactionDataDigest(txBytes)` and
12
+ `getSuiPersonalMessageDigest(messageBytes)` for the intent-prefixed
13
+ blake2b-256 digests the wallet's Ed25519 signer signs, and
14
+ `buildSuiSerializedSignature({ signature, publicKey })` for the 97-byte
15
+ `flag(1) || sig(64) || pubkey(32)` Wallet Standard wire signature.
16
+ - `./chains/sui/buildTransactionFromJson` exports
17
+ `buildSuiTransactionFromJson({ transactionJson, sender })` which hydrates
18
+ a serialized Sui `Transaction` (V1 or V2 JSON) and resolves it to BCS
19
+ bytes via `Transaction.build({ client: getSuiClient() })`. Lets
20
+ extension callers move the build step off the dApp page (where the dApp
21
+ page's Content Security Policy blocks the Sui RPC) and into the
22
+ extension's own context.
23
+
3
24
  ## 2.11.0
4
25
 
5
26
  ### Minor Changes
@@ -0,0 +1,16 @@
1
+ type BuildSuiTransactionFromJsonInput = {
2
+ /** JSON output of `Transaction.toJSON()` or `Transaction.serialize()` (V1 or V2). */
3
+ transactionJson: string;
4
+ /** Sui address of the sender. Used when the serialized transaction omits a sender. */
5
+ sender: string;
6
+ };
7
+ /**
8
+ * Hydrate a serialized Sui Transaction and resolve it to BCS bytes via
9
+ * `Transaction.build({ client })`. Runs inside the SDK so the network call
10
+ * uses the SDK's pinned Sui RPC client and isn't subject to the dApp page's
11
+ * Content Security Policy — callers that run under a dApp's CSP (extension
12
+ * inpage scripts) must route through this from a background context.
13
+ */
14
+ export declare const buildSuiTransactionFromJson: ({ transactionJson, sender, }: BuildSuiTransactionFromJsonInput) => Promise<Uint8Array>;
15
+ export {};
16
+ //# sourceMappingURL=buildTransactionFromJson.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buildTransactionFromJson.d.ts","sourceRoot":"","sources":["../../../../../../packages/core/chain/chains/sui/buildTransactionFromJson.ts"],"names":[],"mappings":"AAIA,KAAK,gCAAgC,GAAG;IACtC,qFAAqF;IACrF,eAAe,EAAE,MAAM,CAAA;IACvB,sFAAsF;IACtF,MAAM,EAAE,MAAM,CAAA;CACf,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,2BAA2B,GAAU,8BAG/C,gCAAgC,KAAG,OAAO,CAAC,UAAU,CAIvD,CAAA"}
@@ -0,0 +1,15 @@
1
+ import { Transaction } from '@mysten/sui/transactions';
2
+ import { getSuiClient } from './client.js';
3
+ /**
4
+ * Hydrate a serialized Sui Transaction and resolve it to BCS bytes via
5
+ * `Transaction.build({ client })`. Runs inside the SDK so the network call
6
+ * uses the SDK's pinned Sui RPC client and isn't subject to the dApp page's
7
+ * Content Security Policy — callers that run under a dApp's CSP (extension
8
+ * inpage scripts) must route through this from a background context.
9
+ */
10
+ export const buildSuiTransactionFromJson = async ({ transactionJson, sender, }) => {
11
+ const tx = Transaction.from(transactionJson);
12
+ tx.setSenderIfNotSet(sender);
13
+ return tx.build({ client: getSuiClient() });
14
+ };
15
+ //# sourceMappingURL=buildTransactionFromJson.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buildTransactionFromJson.js","sourceRoot":"","sources":["../../../../../../packages/core/chain/chains/sui/buildTransactionFromJson.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA;AAEtD,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AASvC;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,KAAK,EAAE,EAChD,eAAe,EACf,MAAM,GAC2B,EAAuB,EAAE;IAC1D,MAAM,EAAE,GAAG,WAAW,CAAC,IAAI,CAAC,eAAe,CAAC,CAAA;IAC5C,EAAE,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAA;IAC5B,OAAO,EAAE,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,YAAY,EAAE,EAAE,CAAC,CAAA;AAC7C,CAAC,CAAA"}
@@ -0,0 +1,25 @@
1
+ export declare const suiTransactionDataIntent: Uint8Array<ArrayBuffer>;
2
+ export declare const suiPersonalMessageIntent: Uint8Array<ArrayBuffer>;
3
+ /**
4
+ * Produce the Sui intent-prefixed blake2b-256 digest of a built PTB. This is
5
+ * the 32-byte hash that the wallet's Ed25519 signer signs.
6
+ */
7
+ export declare const getSuiTransactionDataDigest: (txBytes: Uint8Array) => Uint8Array;
8
+ /**
9
+ * Produce the Sui intent-prefixed blake2b-256 digest of a personal message.
10
+ * The message is BCS-wrapped as `vector<u8>` (uleb128 length || bytes) before
11
+ * hashing.
12
+ */
13
+ export declare const getSuiPersonalMessageDigest: (messageBytes: Uint8Array) => Uint8Array;
14
+ type BuildSuiSerializedSignatureInput = {
15
+ signature: Uint8Array;
16
+ publicKey: Uint8Array;
17
+ };
18
+ /**
19
+ * Assemble a Sui Wallet Standard wire signature for an Ed25519 vault:
20
+ * `flag(1) || signature(64) || publicKey(32)`. The result is 97 bytes; callers
21
+ * typically base64-encode it before returning to the dApp.
22
+ */
23
+ export declare const buildSuiSerializedSignature: ({ signature, publicKey }: BuildSuiSerializedSignatureInput) => Uint8Array;
24
+ export {};
25
+ //# sourceMappingURL=sign.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sign.d.ts","sourceRoot":"","sources":["../../../../../../packages/core/chain/chains/sui/sign.ts"],"names":[],"mappings":"AAaA,eAAO,MAAM,wBAAwB,yBAAgD,CAAA;AACrF,eAAO,MAAM,wBAAwB,yBAAgD,CAAA;AAwBrF;;;GAGG;AACH,eAAO,MAAM,2BAA2B,GAAI,SAAS,UAAU,KAAG,UACW,CAAA;AAE7E;;;;GAIG;AACH,eAAO,MAAM,2BAA2B,GAAI,cAAc,UAAU,KAAG,UAC+C,CAAA;AAMtH,KAAK,gCAAgC,GAAG;IACtC,SAAS,EAAE,UAAU,CAAA;IACrB,SAAS,EAAE,UAAU,CAAA;CACtB,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,2BAA2B,GAAI,0BAA0B,gCAAgC,KAAG,UAYxG,CAAA"}
@@ -0,0 +1,66 @@
1
+ import { blake2b } from '@noble/hashes/blake2';
2
+ /**
3
+ * Sui intent prefixes — `[scope, version, app_id]`. Version is always `0` (V0)
4
+ * and `app_id` is always `0` (Sui). See `@mysten/sui/cryptography/intent`.
5
+ *
6
+ * The public exports are separate `Uint8Array` instances cloned from the
7
+ * private source buffers, so a consumer mutating an imported intent can't
8
+ * corrupt the bytes the digest helpers below feed into every blake2b call.
9
+ */
10
+ const suiTransactionDataIntentBytes = new Uint8Array([0, 0, 0]);
11
+ const suiPersonalMessageIntentBytes = new Uint8Array([3, 0, 0]);
12
+ export const suiTransactionDataIntent = new Uint8Array(suiTransactionDataIntentBytes);
13
+ export const suiPersonalMessageIntent = new Uint8Array(suiPersonalMessageIntentBytes);
14
+ const concatBytes = (...parts) => {
15
+ const total = parts.reduce((n, p) => n + p.length, 0);
16
+ const out = new Uint8Array(total);
17
+ let off = 0;
18
+ for (const p of parts) {
19
+ out.set(p, off);
20
+ off += p.length;
21
+ }
22
+ return out;
23
+ };
24
+ const encodeUleb128 = (n) => {
25
+ const out = [];
26
+ let v = n;
27
+ while (v >= 0x80) {
28
+ out.push((v & 0x7f) | 0x80);
29
+ v >>>= 7;
30
+ }
31
+ out.push(v & 0x7f);
32
+ return new Uint8Array(out);
33
+ };
34
+ /**
35
+ * Produce the Sui intent-prefixed blake2b-256 digest of a built PTB. This is
36
+ * the 32-byte hash that the wallet's Ed25519 signer signs.
37
+ */
38
+ export const getSuiTransactionDataDigest = (txBytes) => blake2b(concatBytes(suiTransactionDataIntentBytes, txBytes), { dkLen: 32 });
39
+ /**
40
+ * Produce the Sui intent-prefixed blake2b-256 digest of a personal message.
41
+ * The message is BCS-wrapped as `vector<u8>` (uleb128 length || bytes) before
42
+ * hashing.
43
+ */
44
+ export const getSuiPersonalMessageDigest = (messageBytes) => blake2b(concatBytes(suiPersonalMessageIntentBytes, encodeUleb128(messageBytes.length), messageBytes), { dkLen: 32 });
45
+ const ed25519SchemeFlag = 0x00;
46
+ const ed25519SignatureLength = 64;
47
+ const ed25519PublicKeyLength = 32;
48
+ /**
49
+ * Assemble a Sui Wallet Standard wire signature for an Ed25519 vault:
50
+ * `flag(1) || signature(64) || publicKey(32)`. The result is 97 bytes; callers
51
+ * typically base64-encode it before returning to the dApp.
52
+ */
53
+ export const buildSuiSerializedSignature = ({ signature, publicKey }) => {
54
+ if (signature.length !== ed25519SignatureLength) {
55
+ throw new Error(`Sui Ed25519 signature must be ${ed25519SignatureLength} bytes, got ${signature.length}`);
56
+ }
57
+ if (publicKey.length !== ed25519PublicKeyLength) {
58
+ throw new Error(`Sui Ed25519 public key must be ${ed25519PublicKeyLength} bytes, got ${publicKey.length}`);
59
+ }
60
+ const out = new Uint8Array(1 + ed25519SignatureLength + ed25519PublicKeyLength);
61
+ out[0] = ed25519SchemeFlag;
62
+ out.set(signature, 1);
63
+ out.set(publicKey, 1 + ed25519SignatureLength);
64
+ return out;
65
+ };
66
+ //# sourceMappingURL=sign.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sign.js","sourceRoot":"","sources":["../../../../../../packages/core/chain/chains/sui/sign.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAA;AAE9C;;;;;;;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GAAG,sBAAsB,CAAC,CAAA;IAC9C,OAAO,GAAG,CAAA;AACZ,CAAC,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vultisig/core-chain",
3
- "version": "2.11.0",
3
+ "version": "2.12.0",
4
4
  "description": "Blockchain chain logic shared across Vultisig clients",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -614,6 +614,11 @@
614
614
  "import": "./dist/chains/solana/spl/getSplAssociatedAccount.js",
615
615
  "default": "./dist/chains/solana/spl/getSplAssociatedAccount.js"
616
616
  },
617
+ "./chains/sui/buildTransactionFromJson": {
618
+ "types": "./dist/chains/sui/buildTransactionFromJson.d.ts",
619
+ "import": "./dist/chains/sui/buildTransactionFromJson.js",
620
+ "default": "./dist/chains/sui/buildTransactionFromJson.js"
621
+ },
617
622
  "./chains/sui/client": {
618
623
  "types": "./dist/chains/sui/client.d.ts",
619
624
  "import": "./dist/chains/sui/client.js",
@@ -624,6 +629,11 @@
624
629
  "import": "./dist/chains/sui/config.js",
625
630
  "default": "./dist/chains/sui/config.js"
626
631
  },
632
+ "./chains/sui/sign": {
633
+ "types": "./dist/chains/sui/sign.d.ts",
634
+ "import": "./dist/chains/sui/sign.js",
635
+ "default": "./dist/chains/sui/sign.js"
636
+ },
627
637
  "./chains/thorchain/ruji/services/fetchMergeableTokenBalances": {
628
638
  "types": "./dist/chains/thorchain/ruji/services/fetchMergeableTokenBalances.d.ts",
629
639
  "import": "./dist/chains/thorchain/ruji/services/fetchMergeableTokenBalances.js",