@mysten/sui 2.36.0 → 2.38.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 +39 -0
- package/dist/bcs/bcs.d.mts.map +1 -1
- package/dist/bcs/bcs.mjs +48 -14
- package/dist/bcs/bcs.mjs.map +1 -1
- package/dist/cryptography/mnemonics.d.mts +4 -1
- package/dist/cryptography/mnemonics.d.mts.map +1 -1
- package/dist/cryptography/mnemonics.mjs +5 -2
- package/dist/cryptography/mnemonics.mjs.map +1 -1
- package/dist/cryptography/slip10.d.mts +5 -0
- package/dist/cryptography/slip10.d.mts.map +1 -0
- package/dist/cryptography/slip10.mjs +55 -0
- package/dist/cryptography/slip10.mjs.map +1 -0
- package/dist/grpc/proto/sui/forking/v1alpha/forking_service.client.d.mts +4 -4
- package/dist/grpc/proto/sui/rpc/v2/ledger_service.client.d.mts +4 -4
- package/dist/grpc/proto/sui/rpc/v2/move_package_service.client.d.mts +4 -4
- package/dist/grpc/proto/sui/rpc/v2/signature_verification_service.client.d.mts +4 -4
- package/dist/grpc/proto/sui/rpc/v2/state_service.client.d.mts +4 -4
- package/dist/grpc/proto/sui/rpc/v2/subscription_service.client.d.mts +4 -4
- package/dist/grpc/proto/sui/rpc/v2/transaction_execution_service.client.d.mts +4 -4
- package/dist/keypairs/ed25519/keypair.d.mts.map +1 -1
- package/dist/keypairs/ed25519/keypair.mjs +6 -9
- package/dist/keypairs/ed25519/keypair.mjs.map +1 -1
- package/dist/keypairs/mldsa65/index.d.mts +3 -2
- package/dist/keypairs/mldsa65/index.mjs +3 -2
- package/dist/keypairs/mldsa65/keypair.d.mts +19 -1
- package/dist/keypairs/mldsa65/keypair.d.mts.map +1 -1
- package/dist/keypairs/mldsa65/keypair.mjs +33 -1
- package/dist/keypairs/mldsa65/keypair.mjs.map +1 -1
- package/dist/multisig/publickey.d.mts +14 -3
- package/dist/multisig/publickey.d.mts.map +1 -1
- package/dist/multisig/publickey.mjs +22 -5
- package/dist/multisig/publickey.mjs.map +1 -1
- package/dist/transactions/Transaction.d.mts +6 -6
- package/dist/transactions/data/internal.d.mts +133 -133
- package/dist/transactions/data/internal.d.mts.map +1 -1
- package/dist/transactions/data/v1.d.mts +239 -239
- package/dist/transactions/data/v1.d.mts.map +1 -1
- package/dist/transactions/data/v2.d.mts +16 -16
- package/dist/transactions/data/v2.d.mts.map +1 -1
- package/dist/verify/verify.d.mts.map +1 -1
- package/dist/verify/verify.mjs +2 -2
- package/dist/verify/verify.mjs.map +1 -1
- package/dist/version.mjs +1 -1
- package/dist/version.mjs.map +1 -1
- package/dist/zklogin/bcs.d.mts +14 -14
- package/dist/zklogin/publickey.d.mts.map +1 -1
- package/dist/zklogin/publickey.mjs +2 -2
- package/dist/zklogin/publickey.mjs.map +1 -1
- package/docs/cryptography/keypairs.md +4 -2
- package/package.json +7 -7
- package/src/bcs/bcs.ts +69 -14
- package/src/cryptography/mnemonics.ts +5 -2
- package/src/cryptography/slip10.ts +84 -0
- package/src/keypairs/ed25519/keypair.ts +11 -14
- package/src/keypairs/mldsa65/index.ts +6 -1
- package/src/keypairs/mldsa65/keypair.ts +46 -0
- package/src/multisig/publickey.ts +55 -14
- package/src/verify/verify.ts +4 -2
- package/src/version.ts +1 -1
- package/src/zklogin/publickey.ts +4 -4
- package/dist/keypairs/ed25519/ed25519-hd-key.mjs +0 -45
- package/dist/keypairs/ed25519/ed25519-hd-key.mjs.map +0 -1
- package/src/keypairs/ed25519/ed25519-hd-key.ts +0 -83
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,44 @@
|
|
|
1
1
|
# @mysten/sui.js
|
|
2
2
|
|
|
3
|
+
## 2.38.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 7b88b72: Add mnemonic derivation for ML-DSA-65: `MLDSA65Keypair.deriveKeypair` and
|
|
8
|
+
`deriveKeypairFromSeed` derive keys at `m/94'/784'/0'/0'/0'` with SLIP-0010 (hardened only,
|
|
9
|
+
`ML-DSA-65 seed` master key), matching `sui keytool`.
|
|
10
|
+
|
|
11
|
+
Ed25519 and ML-DSA-65 share one SLIP-0010 implementation. Derivation paths for both now reject
|
|
12
|
+
indices of 2^31 and above and non-canonical index spellings, which would otherwise wrap onto
|
|
13
|
+
another account, and seeds outside the SLIP-0010 range of 16 to 64 bytes.
|
|
14
|
+
|
|
15
|
+
## 2.37.0
|
|
16
|
+
|
|
17
|
+
### Minor Changes
|
|
18
|
+
|
|
19
|
+
- 785655d: Fix verifying multisig signatures with zkLogin members: the client passed to
|
|
20
|
+
`verifyTransactionSignature`, `verifyPersonalMessageSignature`, `publicKeyFromSuiBytes`, or
|
|
21
|
+
`MultiSigPublicKey.fromPublicKeys` (new optional `client` option) is now used to verify each
|
|
22
|
+
zkLogin member. zkLogin signatures are now verified against the identifier's own address rather
|
|
23
|
+
than one derived from the signature, so a member's signature must come from that member's zkLogin
|
|
24
|
+
identity.
|
|
25
|
+
|
|
26
|
+
### Patch Changes
|
|
27
|
+
|
|
28
|
+
- 3aa65e2: Speed up BCS parsing and serialization: faster ULEB, integer and byte reads and writes,
|
|
29
|
+
enum and option encoding, string decoding, and a single input conversion per write for transformed
|
|
30
|
+
types. Base58, base64 and hex helpers in `@mysten/utils` are faster and no longer depend on
|
|
31
|
+
`@scure/base`. Sui address and object digest encoding is faster.
|
|
32
|
+
|
|
33
|
+
Behaviour changes:
|
|
34
|
+
|
|
35
|
+
- `BcsReader.readBytes` and `readULEB` throw instead of reading past the end of a view into the
|
|
36
|
+
rest of its buffer.
|
|
37
|
+
- `bcs.option(T)` returns `null`/`undefined` when `T` reads as `null`/`undefined` (for example a
|
|
38
|
+
nested option's inner `None`), instead of `true`.
|
|
39
|
+
- `bcs.Address.serializedSize` and `bcs.ObjectDigest.serializedSize` throw on invalid input
|
|
40
|
+
instead of returning a size.
|
|
41
|
+
|
|
3
42
|
## 2.36.0
|
|
4
43
|
|
|
5
44
|
### Minor Changes
|
package/dist/bcs/bcs.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bcs.d.mts","names":[],"sources":["../../src/bcs/bcs.ts"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"bcs.d.mts","names":[],"sources":["../../src/bcs/bcs.ts"],"mappings":";;;;;cA+La,OAAA,EAAO,OAAA,kBAAA,SAAA;AAAA,iBAkMJ,aAAA,WAAwB,OAAA,MAAA,CAAc,CAAA,EAAG,CAAA,mBAAC,SAAA;;WAAA,eAAA,CAAA,OAAA"}
|
package/dist/bcs/bcs.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SUI_ADDRESS_LENGTH, isValidSuiAddress, normalizeSuiAddress } from "../utils/sui-types.mjs";
|
|
2
2
|
import { TypeTagSerializer } from "./type-tag-serializer.mjs";
|
|
3
|
-
import { bcs, fromBase58, fromBase64,
|
|
3
|
+
import { bcs, fromBase58, fromBase64, toBase58, toBase64, toHex } from "@mysten/bcs";
|
|
4
4
|
|
|
5
5
|
//#region src/bcs/bcs.ts
|
|
6
6
|
function unsafe_u64(options) {
|
|
@@ -18,21 +18,55 @@ function optionEnum(type) {
|
|
|
18
18
|
Some: type
|
|
19
19
|
});
|
|
20
20
|
}
|
|
21
|
+
const HEX_NIBBLES = new Int8Array(128).fill(-1);
|
|
22
|
+
for (let i = 0; i < 16; i++) {
|
|
23
|
+
HEX_NIBBLES["0123456789abcdef".charCodeAt(i)] = i;
|
|
24
|
+
HEX_NIBBLES["0123456789ABCDEF".charCodeAt(i)] = i;
|
|
25
|
+
}
|
|
26
|
+
function hexNibble(code) {
|
|
27
|
+
return code < 128 ? HEX_NIBBLES[code] : -1;
|
|
28
|
+
}
|
|
29
|
+
function decodeAddress(value) {
|
|
30
|
+
if (!value) return null;
|
|
31
|
+
const start = value.length >= 2 && value[0] === "0" && (value[1] === "x" || value[1] === "X") ? 2 : 0;
|
|
32
|
+
if (value.length - start > SUI_ADDRESS_LENGTH * 2) return null;
|
|
33
|
+
const bytes = new Uint8Array(SUI_ADDRESS_LENGTH);
|
|
34
|
+
let byteIndex = SUI_ADDRESS_LENGTH - 1;
|
|
35
|
+
let i = value.length - 1;
|
|
36
|
+
for (; i >= start + 1; i -= 2) {
|
|
37
|
+
const low = hexNibble(value.charCodeAt(i));
|
|
38
|
+
const high = hexNibble(value.charCodeAt(i - 1));
|
|
39
|
+
if (low < 0 || high < 0) return null;
|
|
40
|
+
bytes[byteIndex--] = high << 4 | low;
|
|
41
|
+
}
|
|
42
|
+
if (i === start) {
|
|
43
|
+
const low = hexNibble(value.charCodeAt(i));
|
|
44
|
+
if (low < 0) return null;
|
|
45
|
+
bytes[byteIndex] = low;
|
|
46
|
+
}
|
|
47
|
+
return bytes;
|
|
48
|
+
}
|
|
21
49
|
const Address = bcs.bytes(SUI_ADDRESS_LENGTH).transform({
|
|
22
|
-
|
|
23
|
-
|
|
50
|
+
input: (val) => {
|
|
51
|
+
if (typeof val === "string") {
|
|
52
|
+
const bytes = decodeAddress(val);
|
|
53
|
+
if (!bytes) throw new Error(`Invalid Sui address ${val}`);
|
|
54
|
+
return bytes;
|
|
55
|
+
}
|
|
56
|
+
const address = toHex(val);
|
|
24
57
|
if (!address || !isValidSuiAddress(normalizeSuiAddress(address))) throw new Error(`Invalid Sui address ${address}`);
|
|
58
|
+
return val;
|
|
25
59
|
},
|
|
26
|
-
|
|
27
|
-
output: (val) => normalizeSuiAddress(toHex(val))
|
|
60
|
+
output: (val) => `0x${toHex(val)}`
|
|
28
61
|
});
|
|
29
62
|
const ObjectDigest = bcs.byteVector().transform({
|
|
30
63
|
name: "ObjectDigest",
|
|
31
|
-
input: (value) =>
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
64
|
+
input: (value) => {
|
|
65
|
+
const bytes = fromBase58(value);
|
|
66
|
+
if (bytes.length !== 32) throw new Error("ObjectDigest must be 32 bytes");
|
|
67
|
+
return bytes;
|
|
68
|
+
},
|
|
69
|
+
output: (value) => toBase58(value)
|
|
36
70
|
});
|
|
37
71
|
const SuiObjectRef = bcs.struct("SuiObjectRef", {
|
|
38
72
|
objectId: Address,
|
|
@@ -77,7 +111,7 @@ const FundsWithdrawal = bcs.struct("FundsWithdrawal", {
|
|
|
77
111
|
const CallArg = bcs.enum("CallArg", {
|
|
78
112
|
Pure: bcs.struct("Pure", { bytes: bcs.byteVector().transform({
|
|
79
113
|
input: (val) => typeof val === "string" ? fromBase64(val) : val,
|
|
80
|
-
output: (val) => toBase64(
|
|
114
|
+
output: (val) => toBase64(val)
|
|
81
115
|
}) }),
|
|
82
116
|
Object: ObjectArg,
|
|
83
117
|
FundsWithdrawal
|
|
@@ -129,7 +163,7 @@ const Command = bcs.enum("Command", {
|
|
|
129
163
|
Publish: bcs.struct("Publish", {
|
|
130
164
|
modules: bcs.vector(bcs.byteVector().transform({
|
|
131
165
|
input: (val) => typeof val === "string" ? fromBase64(val) : val,
|
|
132
|
-
output: (val) => toBase64(
|
|
166
|
+
output: (val) => toBase64(val)
|
|
133
167
|
})),
|
|
134
168
|
dependencies: bcs.vector(Address)
|
|
135
169
|
}),
|
|
@@ -143,7 +177,7 @@ const Command = bcs.enum("Command", {
|
|
|
143
177
|
Upgrade: bcs.struct("Upgrade", {
|
|
144
178
|
modules: bcs.vector(bcs.byteVector().transform({
|
|
145
179
|
input: (val) => typeof val === "string" ? fromBase64(val) : val,
|
|
146
|
-
output: (val) => toBase64(
|
|
180
|
+
output: (val) => toBase64(val)
|
|
147
181
|
})),
|
|
148
182
|
dependencies: bcs.vector(Address),
|
|
149
183
|
package: Address,
|
|
@@ -256,7 +290,7 @@ const MultiSig = bcs.struct("MultiSig", {
|
|
|
256
290
|
});
|
|
257
291
|
const base64String = bcs.byteVector().transform({
|
|
258
292
|
input: (val) => typeof val === "string" ? fromBase64(val) : val,
|
|
259
|
-
output: (val) => toBase64(
|
|
293
|
+
output: (val) => toBase64(val)
|
|
260
294
|
});
|
|
261
295
|
const PasskeyAuthenticator = bcs.struct("PasskeyAuthenticator", {
|
|
262
296
|
authenticatorData: bcs.byteVector(),
|
package/dist/bcs/bcs.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bcs.mjs","names":[],"sources":["../../src/bcs/bcs.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { BcsType, BcsTypeOptions } from '@mysten/bcs';\nimport { bcs, fromBase58, fromBase64, fromHex, toBase58, toBase64, toHex } from '@mysten/bcs';\n\nimport { isValidSuiAddress, normalizeSuiAddress, SUI_ADDRESS_LENGTH } from '../utils/sui-types.js';\nimport { TypeTagSerializer } from './type-tag-serializer.js';\nimport type { TypeTag as TypeTagType } from './types.js';\n\nfunction unsafe_u64(options?: BcsTypeOptions<number>) {\n\treturn bcs\n\t\t.u64({\n\t\t\tname: 'unsafe_u64',\n\t\t\t...(options as object),\n\t\t})\n\t\t.transform({\n\t\t\tinput: (val: number | string) => val,\n\t\t\toutput: (val) => Number(val),\n\t\t});\n}\n\nfunction optionEnum<T extends BcsType<any, any>>(type: T) {\n\treturn bcs.enum('Option', {\n\t\tNone: null,\n\t\tSome: type,\n\t});\n}\n\nexport const Address = bcs.bytes(SUI_ADDRESS_LENGTH).transform({\n\tvalidate: (val) => {\n\t\tconst address = typeof val === 'string' ? val : toHex(val);\n\t\tif (!address || !isValidSuiAddress(normalizeSuiAddress(address))) {\n\t\t\tthrow new Error(`Invalid Sui address ${address}`);\n\t\t}\n\t},\n\tinput: (val: string | Uint8Array) =>\n\t\ttypeof val === 'string' ? fromHex(normalizeSuiAddress(val)) : val,\n\toutput: (val) => normalizeSuiAddress(toHex(val)),\n});\n\nexport const ObjectDigest = bcs.byteVector().transform({\n\tname: 'ObjectDigest',\n\tinput: (value: string) => fromBase58(value),\n\toutput: (value) => toBase58(new Uint8Array(value)),\n\tvalidate: (value) => {\n\t\tif (fromBase58(value).length !== 32) {\n\t\t\tthrow new Error('ObjectDigest must be 32 bytes');\n\t\t}\n\t},\n});\n\nexport const SuiObjectRef = bcs.struct('SuiObjectRef', {\n\tobjectId: Address,\n\tversion: bcs.u64(),\n\tdigest: ObjectDigest,\n});\n\nexport const SharedObjectRef = bcs.struct('SharedObjectRef', {\n\tobjectId: Address,\n\tinitialSharedVersion: bcs.u64(),\n\tmutable: bcs.bool(),\n});\n\nexport const ObjectArg = bcs.enum('ObjectArg', {\n\tImmOrOwnedObject: SuiObjectRef,\n\tSharedObject: SharedObjectRef,\n\tReceiving: SuiObjectRef,\n});\n\n// Rust: crates/sui-types/src/object.rs\nexport const Owner = bcs.enum('Owner', {\n\tAddressOwner: Address,\n\tObjectOwner: Address,\n\tShared: bcs.struct('Shared', {\n\t\tinitialSharedVersion: bcs.u64(),\n\t}),\n\tImmutable: null,\n\tConsensusAddressOwner: bcs.struct('ConsensusAddressOwner', {\n\t\tstartVersion: bcs.u64(),\n\t\towner: Address,\n\t}),\n});\n\n// Rust: crates/sui-types/src/transaction.rs\nexport const Reservation = bcs.enum('Reservation', {\n\tMaxAmountU64: bcs.u64(),\n});\n\n// Rust: crates/sui-types/src/transaction.rs\nexport const WithdrawalType = bcs.enum('WithdrawalType', {\n\tBalance: bcs.lazy(() => TypeTag),\n});\n\n// Rust: crates/sui-types/src/transaction.rs\nexport const WithdrawFrom = bcs.enum('WithdrawFrom', {\n\tSender: null,\n\tSponsor: null,\n\tSenderAllowance: bcs.struct('SenderAllowance', {\n\t\tfunder: Address,\n\t\tallowance: Address,\n\t}),\n});\n\n// Rust: crates/sui-types/src/transaction.rs\nexport const FundsWithdrawal = bcs.struct('FundsWithdrawal', {\n\treservation: Reservation,\n\ttypeArg: WithdrawalType,\n\twithdrawFrom: WithdrawFrom,\n});\n\nexport const CallArg = bcs.enum('CallArg', {\n\tPure: bcs.struct('Pure', {\n\t\tbytes: bcs.byteVector().transform({\n\t\t\tinput: (val: string | Uint8Array) => (typeof val === 'string' ? fromBase64(val) : val),\n\t\t\toutput: (val) => toBase64(new Uint8Array(val)),\n\t\t}),\n\t}),\n\tObject: ObjectArg,\n\tFundsWithdrawal: FundsWithdrawal,\n});\n\nconst InnerTypeTag: BcsType<TypeTagType, TypeTagType> = bcs.enum('TypeTag', {\n\tbool: null,\n\tu8: null,\n\tu64: null,\n\tu128: null,\n\taddress: null,\n\tsigner: null,\n\tvector: bcs.lazy(() => InnerTypeTag),\n\tstruct: bcs.lazy(() => StructTag),\n\tu16: null,\n\tu32: null,\n\tu256: null,\n}) as BcsType<TypeTagType>;\n\nexport const TypeTag = InnerTypeTag.transform({\n\tinput: (typeTag: string | TypeTagType) =>\n\t\ttypeof typeTag === 'string' ? TypeTagSerializer.parseFromStr(typeTag, true) : typeTag,\n\toutput: (typeTag: TypeTagType) => TypeTagSerializer.tagToString(typeTag),\n});\n\nexport const Argument = bcs.enum('Argument', {\n\tGasCoin: null,\n\tInput: bcs.u16(),\n\tResult: bcs.u16(),\n\tNestedResult: bcs.tuple([bcs.u16(), bcs.u16()]),\n});\n\nexport const ProgrammableMoveCall = bcs.struct('ProgrammableMoveCall', {\n\tpackage: Address,\n\tmodule: bcs.string(),\n\tfunction: bcs.string(),\n\ttypeArguments: bcs.vector(TypeTag),\n\targuments: bcs.vector(Argument),\n});\n\nexport const Command = bcs.enum('Command', {\n\t/**\n\t * A Move Call - any public Move function can be called via\n\t * this transaction. The results can be used that instant to pass\n\t * into the next transaction.\n\t */\n\tMoveCall: ProgrammableMoveCall,\n\t/**\n\t * Transfer vector of objects to a receiver.\n\t */\n\tTransferObjects: bcs.struct('TransferObjects', {\n\t\tobjects: bcs.vector(Argument),\n\t\taddress: Argument,\n\t}),\n\t// /**\n\t// * Split `amount` from a `coin`.\n\t// */\n\tSplitCoins: bcs.struct('SplitCoins', {\n\t\tcoin: Argument,\n\t\tamounts: bcs.vector(Argument),\n\t}),\n\t// /**\n\t// * Merge Vector of Coins (`sources`) into a `destination`.\n\t// */\n\tMergeCoins: bcs.struct('MergeCoins', {\n\t\tdestination: Argument,\n\t\tsources: bcs.vector(Argument),\n\t}),\n\t// /**\n\t// * Publish a Move module.\n\t// */\n\tPublish: bcs.struct('Publish', {\n\t\tmodules: bcs.vector(\n\t\t\tbcs.byteVector().transform({\n\t\t\t\tinput: (val: string | Uint8Array) => (typeof val === 'string' ? fromBase64(val) : val),\n\t\t\t\toutput: (val) => toBase64(new Uint8Array(val)),\n\t\t\t}),\n\t\t),\n\t\tdependencies: bcs.vector(Address),\n\t}),\n\t// /**\n\t// * Build a vector of objects using the input arguments.\n\t// * It is impossible to export construct a `vector<T: key>` otherwise,\n\t// * so this call serves a utility function.\n\t// */\n\tMakeMoveVec: bcs.struct('MakeMoveVec', {\n\t\ttype: optionEnum(TypeTag).transform({\n\t\t\tinput: (val: string | null) =>\n\t\t\t\tval === null\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tNone: true,\n\t\t\t\t\t\t}\n\t\t\t\t\t: {\n\t\t\t\t\t\t\tSome: val,\n\t\t\t\t\t\t},\n\t\t\toutput: (val) => val.Some ?? null,\n\t\t}),\n\t\telements: bcs.vector(Argument),\n\t}),\n\tUpgrade: bcs.struct('Upgrade', {\n\t\tmodules: bcs.vector(\n\t\t\tbcs.byteVector().transform({\n\t\t\t\tinput: (val: string | Uint8Array) => (typeof val === 'string' ? fromBase64(val) : val),\n\t\t\t\toutput: (val) => toBase64(new Uint8Array(val)),\n\t\t\t}),\n\t\t),\n\t\tdependencies: bcs.vector(Address),\n\t\tpackage: Address,\n\t\tticket: Argument,\n\t}),\n});\n\nexport const ProgrammableTransaction = bcs.struct('ProgrammableTransaction', {\n\tinputs: bcs.vector(CallArg),\n\tcommands: bcs.vector(Command),\n});\n\n// Rust: crates/sui-types/src/transaction.rs\nexport const ValidDuring = bcs.struct('ValidDuring', {\n\tminEpoch: bcs.option(bcs.u64()),\n\tmaxEpoch: bcs.option(bcs.u64()),\n\tminTimestamp: bcs.option(bcs.u64()),\n\tmaxTimestamp: bcs.option(bcs.u64()),\n\tchain: ObjectDigest,\n\tnonce: bcs.u32(),\n});\n\nexport function assertAllowedProposersNotEmpty(proposers: number[]) {\n\tif (proposers.length === 0) {\n\t\tthrow new Error('Allowed proposers must not be empty');\n\t}\n\n\treturn proposers;\n}\n\nexport function assertAllowedProposersStrictlyIncreasing(proposers: number[]) {\n\tassertAllowedProposersNotEmpty(proposers);\n\n\tfor (let i = 1; i < proposers.length; i++) {\n\t\tif (proposers[i] <= proposers[i - 1]) {\n\t\t\tthrow new Error('Allowed proposers must be strictly increasing');\n\t\t}\n\t}\n\n\treturn proposers;\n}\n\n// Upstream only checks sortedness in `validity_check`, on submission, so decoding an unsorted\n// set must succeed. Empty is a deserialization error there, and here.\nconst AllowedProposerIndices = bcs.vector(bcs.u32()).transform({\n\tinput: assertAllowedProposersStrictlyIncreasing,\n\toutput: assertAllowedProposersNotEmpty,\n});\n\n// Rust: crates/sui-types/src/transaction.rs\nexport const AllowedProposers = bcs.struct('AllowedProposers', {\n\tepoch: bcs.u64(),\n\tproposers: AllowedProposerIndices,\n});\n\n// Rust: crates/sui-types/src/transaction.rs\nexport const Validity = bcs.struct('Validity', {\n\tminEpoch: bcs.option(bcs.u64()),\n\tmaxEpoch: bcs.option(bcs.u64()),\n\tminTimestamp: bcs.option(bcs.u64()),\n\tmaxTimestamp: bcs.option(bcs.u64()),\n\tchain: ObjectDigest,\n\tnonce: bcs.u32(),\n\tallowedProposers: bcs.option(AllowedProposers),\n});\n\nexport const TransactionExpiration = bcs.enum('TransactionExpiration', {\n\tNone: null,\n\tEpoch: unsafe_u64(),\n\tValidDuring: ValidDuring,\n\tValidity,\n});\n\nexport const StructTag = bcs.struct('StructTag', {\n\taddress: Address,\n\tmodule: bcs.string(),\n\tname: bcs.string(),\n\ttypeParams: bcs.vector(InnerTypeTag),\n});\n\nexport const GasData = bcs.struct('GasData', {\n\tpayment: bcs.vector(SuiObjectRef),\n\towner: Address,\n\tprice: bcs.u64(),\n\tbudget: bcs.u64(),\n});\n\nexport const IntentScope = bcs.enum('IntentScope', {\n\tTransactionData: null,\n\tTransactionEffects: null,\n\tCheckpointSummary: null,\n\tPersonalMessage: null,\n});\n\nexport const IntentVersion = bcs.enum('IntentVersion', {\n\tV0: null,\n});\n\nexport const AppId = bcs.enum('AppId', {\n\tSui: null,\n});\n\nexport const Intent = bcs.struct('Intent', {\n\tscope: IntentScope,\n\tversion: IntentVersion,\n\tappId: AppId,\n});\n\nexport function IntentMessage<T extends BcsType<any>>(T: T) {\n\treturn bcs.struct(`IntentMessage<${T.name}>`, {\n\t\tintent: Intent,\n\t\tvalue: T,\n\t});\n}\n\nexport const CompressedSignature = bcs.enum('CompressedSignature', {\n\tED25519: bcs.bytes(64),\n\tSecp256k1: bcs.bytes(64),\n\tSecp256r1: bcs.bytes(64),\n\tZkLogin: bcs.byteVector(),\n\tPasskey: bcs.byteVector(),\n\tMLDSA65: bcs.bytes(3309),\n});\n\n// Variant order must match Sui's `PublicKey` enum, which validators hash to\n// derive a multisig address.\nexport const PublicKey = bcs.enum('PublicKey', {\n\tED25519: bcs.bytes(32),\n\tSecp256k1: bcs.bytes(33),\n\tSecp256r1: bcs.bytes(33),\n\tZkLogin: bcs.byteVector(),\n\tPasskey: bcs.bytes(33),\n\tMLDSA65: bcs.bytes(1952),\n});\n\nexport const MultiSigPkMap = bcs.struct('MultiSigPkMap', {\n\tpubKey: PublicKey,\n\tweight: bcs.u8(),\n});\n\nexport const MultiSigPublicKey = bcs.struct('MultiSigPublicKey', {\n\tpk_map: bcs.vector(MultiSigPkMap),\n\tthreshold: bcs.u16(),\n});\n\nexport const MultiSig = bcs.struct('MultiSig', {\n\tsigs: bcs.vector(CompressedSignature),\n\tbitmap: bcs.u16(),\n\tmultisig_pk: MultiSigPublicKey,\n});\n\nexport const base64String = bcs.byteVector().transform({\n\tinput: (val: string | Uint8Array) => (typeof val === 'string' ? fromBase64(val) : val),\n\toutput: (val) => toBase64(new Uint8Array(val)),\n});\n\nexport const PasskeyAuthenticator = bcs.struct('PasskeyAuthenticator', {\n\tauthenticatorData: bcs.byteVector(),\n\tclientDataJson: bcs.string(),\n\tuserSignature: bcs.byteVector(),\n});\n\n// Rust: crates/sui-types/src/object.rs\nexport const MoveObjectType = bcs.enum('MoveObjectType', {\n\tOther: StructTag,\n\tGasCoin: null,\n\tStakedSui: null,\n\tCoin: TypeTag,\n\tAccumulatorBalanceWrapper: null,\n});\n\n// Rust: crates/sui-types/src/object.rs\nexport const TypeOrigin = bcs.struct('TypeOrigin', {\n\tmoduleName: bcs.string(),\n\tdatatypeName: bcs.string(),\n\tpackage: Address,\n});\n\n// Rust: crates/sui-types/src/object.rs\nexport const UpgradeInfo = bcs.struct('UpgradeInfo', {\n\tupgradedId: Address,\n\tupgradedVersion: bcs.u64(),\n});\n\n// Rust: crates/sui-types/src/object.rs\nexport const MovePackage = bcs.struct('MovePackage', {\n\tid: Address,\n\tversion: bcs.u64(),\n\tmoduleMap: bcs.map(bcs.string(), bcs.byteVector()),\n\ttypeOriginTable: bcs.vector(TypeOrigin),\n\tlinkageTable: bcs.map(Address, UpgradeInfo),\n});\n\n// Rust: crates/sui-types/src/object.rs\nexport const MoveObject = bcs.struct('MoveObject', {\n\ttype: MoveObjectType,\n\thasPublicTransfer: bcs.bool(),\n\tversion: bcs.u64(),\n\tcontents: bcs.byteVector(),\n});\n\n// Rust: crates/sui-types/src/object.rs\nexport const Data = bcs.enum('Data', {\n\tMove: MoveObject,\n\tPackage: MovePackage,\n});\n\n// Rust: crates/sui-types/src/object.rs\nexport const ObjectInner = bcs.struct('ObjectInner', {\n\tdata: Data,\n\towner: Owner,\n\tpreviousTransaction: ObjectDigest,\n\tstorageRebate: bcs.u64(),\n});\n"],"mappings":";;;;;AAUA,SAAS,WAAW,SAAkC;AACrD,QAAO,IACL,IAAI;EACJ,MAAM;EACN,GAAI;EACJ,CAAC,CACD,UAAU;EACV,QAAQ,QAAyB;EACjC,SAAS,QAAQ,OAAO,IAAI;EAC5B,CAAC;;AAGJ,SAAS,WAAwC,MAA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Ae;CACpD,MAAM;CACN,OAAO;CACP,qBAAqB;CACrB,eAAe,IAAI,KAAK;CACxB,CAAC"}
|
|
1
|
+
{"version":3,"file":"bcs.mjs","names":[],"sources":["../../src/bcs/bcs.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { BcsType, BcsTypeOptions } from '@mysten/bcs';\nimport { bcs, fromBase58, fromBase64, toBase58, toBase64, toHex } from '@mysten/bcs';\n\nimport { isValidSuiAddress, normalizeSuiAddress, SUI_ADDRESS_LENGTH } from '../utils/sui-types.js';\nimport { TypeTagSerializer } from './type-tag-serializer.js';\nimport type { TypeTag as TypeTagType } from './types.js';\n\nfunction unsafe_u64(options?: BcsTypeOptions<number>) {\n\treturn bcs\n\t\t.u64({\n\t\t\tname: 'unsafe_u64',\n\t\t\t...(options as object),\n\t\t})\n\t\t.transform({\n\t\t\tinput: (val: number | string) => val,\n\t\t\toutput: (val) => Number(val),\n\t\t});\n}\n\nfunction optionEnum<T extends BcsType<any, any>>(type: T) {\n\treturn bcs.enum('Option', {\n\t\tNone: null,\n\t\tSome: type,\n\t});\n}\n\nconst HEX_NIBBLES = new Int8Array(128).fill(-1);\nfor (let i = 0; i < 16; i++) {\n\tHEX_NIBBLES['0123456789abcdef'.charCodeAt(i)] = i;\n\tHEX_NIBBLES['0123456789ABCDEF'.charCodeAt(i)] = i;\n}\nfunction hexNibble(code: number): number {\n\treturn code < 128 ? HEX_NIBBLES[code] : -1;\n}\n\n// Same bytes as fromHex(normalizeSuiAddress(value)) for valid addresses, or null for invalid ones\nfunction decodeAddress(value: string): Uint8Array<ArrayBuffer> | null {\n\tif (!value) {\n\t\treturn null;\n\t}\n\tconst start =\n\t\tvalue.length >= 2 && value[0] === '0' && (value[1] === 'x' || value[1] === 'X') ? 2 : 0;\n\tconst digits = value.length - start;\n\tif (digits > SUI_ADDRESS_LENGTH * 2) {\n\t\treturn null;\n\t}\n\n\tconst bytes = new Uint8Array(SUI_ADDRESS_LENGTH);\n\t// Right-align the digits, as normalizeSuiAddress left-pads with zeros\n\tlet byteIndex = SUI_ADDRESS_LENGTH - 1;\n\tlet i = value.length - 1;\n\tfor (; i >= start + 1; i -= 2) {\n\t\tconst low = hexNibble(value.charCodeAt(i));\n\t\tconst high = hexNibble(value.charCodeAt(i - 1));\n\t\tif (low < 0 || high < 0) {\n\t\t\treturn null;\n\t\t}\n\t\tbytes[byteIndex--] = (high << 4) | low;\n\t}\n\tif (i === start) {\n\t\tconst low = hexNibble(value.charCodeAt(i));\n\t\tif (low < 0) {\n\t\t\treturn null;\n\t\t}\n\t\tbytes[byteIndex] = low;\n\t}\n\n\treturn bytes;\n}\n\nexport const Address = bcs.bytes(SUI_ADDRESS_LENGTH).transform({\n\t// Validation lives in input so string addresses are only decoded once per write; transform's\n\t// validate runs input, so validate() still rejects invalid addresses.\n\tinput: (val: string | Uint8Array) => {\n\t\tif (typeof val === 'string') {\n\t\t\tconst bytes = decodeAddress(val);\n\t\t\tif (!bytes) {\n\t\t\t\tthrow new Error(`Invalid Sui address ${val}`);\n\t\t\t}\n\t\t\treturn bytes;\n\t\t}\n\t\tconst address = toHex(val);\n\t\tif (!address || !isValidSuiAddress(normalizeSuiAddress(address))) {\n\t\t\tthrow new Error(`Invalid Sui address ${address}`);\n\t\t}\n\t\treturn val;\n\t},\n\toutput: (val) => `0x${toHex(val)}`,\n});\n\nexport const ObjectDigest = bcs.byteVector().transform({\n\tname: 'ObjectDigest',\n\t// The length check lives in input so the digest is only base58-decoded once per write;\n\t// transform's validate runs input, so validate() still rejects digests of the wrong length.\n\tinput: (value: string) => {\n\t\tconst bytes = fromBase58(value);\n\t\tif (bytes.length !== 32) {\n\t\t\tthrow new Error('ObjectDigest must be 32 bytes');\n\t\t}\n\t\treturn bytes;\n\t},\n\toutput: (value) => toBase58(value),\n});\n\nexport const SuiObjectRef = bcs.struct('SuiObjectRef', {\n\tobjectId: Address,\n\tversion: bcs.u64(),\n\tdigest: ObjectDigest,\n});\n\nexport const SharedObjectRef = bcs.struct('SharedObjectRef', {\n\tobjectId: Address,\n\tinitialSharedVersion: bcs.u64(),\n\tmutable: bcs.bool(),\n});\n\nexport const ObjectArg = bcs.enum('ObjectArg', {\n\tImmOrOwnedObject: SuiObjectRef,\n\tSharedObject: SharedObjectRef,\n\tReceiving: SuiObjectRef,\n});\n\n// Rust: crates/sui-types/src/object.rs\nexport const Owner = bcs.enum('Owner', {\n\tAddressOwner: Address,\n\tObjectOwner: Address,\n\tShared: bcs.struct('Shared', {\n\t\tinitialSharedVersion: bcs.u64(),\n\t}),\n\tImmutable: null,\n\tConsensusAddressOwner: bcs.struct('ConsensusAddressOwner', {\n\t\tstartVersion: bcs.u64(),\n\t\towner: Address,\n\t}),\n});\n\n// Rust: crates/sui-types/src/transaction.rs\nexport const Reservation = bcs.enum('Reservation', {\n\tMaxAmountU64: bcs.u64(),\n});\n\n// Rust: crates/sui-types/src/transaction.rs\nexport const WithdrawalType = bcs.enum('WithdrawalType', {\n\tBalance: bcs.lazy(() => TypeTag),\n});\n\n// Rust: crates/sui-types/src/transaction.rs\nexport const WithdrawFrom = bcs.enum('WithdrawFrom', {\n\tSender: null,\n\tSponsor: null,\n\tSenderAllowance: bcs.struct('SenderAllowance', {\n\t\tfunder: Address,\n\t\tallowance: Address,\n\t}),\n});\n\n// Rust: crates/sui-types/src/transaction.rs\nexport const FundsWithdrawal = bcs.struct('FundsWithdrawal', {\n\treservation: Reservation,\n\ttypeArg: WithdrawalType,\n\twithdrawFrom: WithdrawFrom,\n});\n\nexport const CallArg = bcs.enum('CallArg', {\n\tPure: bcs.struct('Pure', {\n\t\tbytes: bcs.byteVector().transform({\n\t\t\tinput: (val: string | Uint8Array) => (typeof val === 'string' ? fromBase64(val) : val),\n\t\t\toutput: (val) => toBase64(val),\n\t\t}),\n\t}),\n\tObject: ObjectArg,\n\tFundsWithdrawal: FundsWithdrawal,\n});\n\nconst InnerTypeTag: BcsType<TypeTagType, TypeTagType> = bcs.enum('TypeTag', {\n\tbool: null,\n\tu8: null,\n\tu64: null,\n\tu128: null,\n\taddress: null,\n\tsigner: null,\n\tvector: bcs.lazy(() => InnerTypeTag),\n\tstruct: bcs.lazy(() => StructTag),\n\tu16: null,\n\tu32: null,\n\tu256: null,\n}) as BcsType<TypeTagType>;\n\nexport const TypeTag = InnerTypeTag.transform({\n\tinput: (typeTag: string | TypeTagType) =>\n\t\ttypeof typeTag === 'string' ? TypeTagSerializer.parseFromStr(typeTag, true) : typeTag,\n\toutput: (typeTag: TypeTagType) => TypeTagSerializer.tagToString(typeTag),\n});\n\nexport const Argument = bcs.enum('Argument', {\n\tGasCoin: null,\n\tInput: bcs.u16(),\n\tResult: bcs.u16(),\n\tNestedResult: bcs.tuple([bcs.u16(), bcs.u16()]),\n});\n\nexport const ProgrammableMoveCall = bcs.struct('ProgrammableMoveCall', {\n\tpackage: Address,\n\tmodule: bcs.string(),\n\tfunction: bcs.string(),\n\ttypeArguments: bcs.vector(TypeTag),\n\targuments: bcs.vector(Argument),\n});\n\nexport const Command = bcs.enum('Command', {\n\t/**\n\t * A Move Call - any public Move function can be called via\n\t * this transaction. The results can be used that instant to pass\n\t * into the next transaction.\n\t */\n\tMoveCall: ProgrammableMoveCall,\n\t/**\n\t * Transfer vector of objects to a receiver.\n\t */\n\tTransferObjects: bcs.struct('TransferObjects', {\n\t\tobjects: bcs.vector(Argument),\n\t\taddress: Argument,\n\t}),\n\t// /**\n\t// * Split `amount` from a `coin`.\n\t// */\n\tSplitCoins: bcs.struct('SplitCoins', {\n\t\tcoin: Argument,\n\t\tamounts: bcs.vector(Argument),\n\t}),\n\t// /**\n\t// * Merge Vector of Coins (`sources`) into a `destination`.\n\t// */\n\tMergeCoins: bcs.struct('MergeCoins', {\n\t\tdestination: Argument,\n\t\tsources: bcs.vector(Argument),\n\t}),\n\t// /**\n\t// * Publish a Move module.\n\t// */\n\tPublish: bcs.struct('Publish', {\n\t\tmodules: bcs.vector(\n\t\t\tbcs.byteVector().transform({\n\t\t\t\tinput: (val: string | Uint8Array) => (typeof val === 'string' ? fromBase64(val) : val),\n\t\t\t\toutput: (val) => toBase64(val),\n\t\t\t}),\n\t\t),\n\t\tdependencies: bcs.vector(Address),\n\t}),\n\t// /**\n\t// * Build a vector of objects using the input arguments.\n\t// * It is impossible to export construct a `vector<T: key>` otherwise,\n\t// * so this call serves a utility function.\n\t// */\n\tMakeMoveVec: bcs.struct('MakeMoveVec', {\n\t\ttype: optionEnum(TypeTag).transform({\n\t\t\tinput: (val: string | null) =>\n\t\t\t\tval === null\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tNone: true,\n\t\t\t\t\t\t}\n\t\t\t\t\t: {\n\t\t\t\t\t\t\tSome: val,\n\t\t\t\t\t\t},\n\t\t\toutput: (val) => val.Some ?? null,\n\t\t}),\n\t\telements: bcs.vector(Argument),\n\t}),\n\tUpgrade: bcs.struct('Upgrade', {\n\t\tmodules: bcs.vector(\n\t\t\tbcs.byteVector().transform({\n\t\t\t\tinput: (val: string | Uint8Array) => (typeof val === 'string' ? fromBase64(val) : val),\n\t\t\t\toutput: (val) => toBase64(val),\n\t\t\t}),\n\t\t),\n\t\tdependencies: bcs.vector(Address),\n\t\tpackage: Address,\n\t\tticket: Argument,\n\t}),\n});\n\nexport const ProgrammableTransaction = bcs.struct('ProgrammableTransaction', {\n\tinputs: bcs.vector(CallArg),\n\tcommands: bcs.vector(Command),\n});\n\n// Rust: crates/sui-types/src/transaction.rs\nexport const ValidDuring = bcs.struct('ValidDuring', {\n\tminEpoch: bcs.option(bcs.u64()),\n\tmaxEpoch: bcs.option(bcs.u64()),\n\tminTimestamp: bcs.option(bcs.u64()),\n\tmaxTimestamp: bcs.option(bcs.u64()),\n\tchain: ObjectDigest,\n\tnonce: bcs.u32(),\n});\n\nexport function assertAllowedProposersNotEmpty(proposers: number[]) {\n\tif (proposers.length === 0) {\n\t\tthrow new Error('Allowed proposers must not be empty');\n\t}\n\n\treturn proposers;\n}\n\nexport function assertAllowedProposersStrictlyIncreasing(proposers: number[]) {\n\tassertAllowedProposersNotEmpty(proposers);\n\n\tfor (let i = 1; i < proposers.length; i++) {\n\t\tif (proposers[i] <= proposers[i - 1]) {\n\t\t\tthrow new Error('Allowed proposers must be strictly increasing');\n\t\t}\n\t}\n\n\treturn proposers;\n}\n\n// Upstream only checks sortedness in `validity_check`, on submission, so decoding an unsorted\n// set must succeed. Empty is a deserialization error there, and here.\nconst AllowedProposerIndices = bcs.vector(bcs.u32()).transform({\n\tinput: assertAllowedProposersStrictlyIncreasing,\n\toutput: assertAllowedProposersNotEmpty,\n});\n\n// Rust: crates/sui-types/src/transaction.rs\nexport const AllowedProposers = bcs.struct('AllowedProposers', {\n\tepoch: bcs.u64(),\n\tproposers: AllowedProposerIndices,\n});\n\n// Rust: crates/sui-types/src/transaction.rs\nexport const Validity = bcs.struct('Validity', {\n\tminEpoch: bcs.option(bcs.u64()),\n\tmaxEpoch: bcs.option(bcs.u64()),\n\tminTimestamp: bcs.option(bcs.u64()),\n\tmaxTimestamp: bcs.option(bcs.u64()),\n\tchain: ObjectDigest,\n\tnonce: bcs.u32(),\n\tallowedProposers: bcs.option(AllowedProposers),\n});\n\nexport const TransactionExpiration = bcs.enum('TransactionExpiration', {\n\tNone: null,\n\tEpoch: unsafe_u64(),\n\tValidDuring: ValidDuring,\n\tValidity,\n});\n\nexport const StructTag = bcs.struct('StructTag', {\n\taddress: Address,\n\tmodule: bcs.string(),\n\tname: bcs.string(),\n\ttypeParams: bcs.vector(InnerTypeTag),\n});\n\nexport const GasData = bcs.struct('GasData', {\n\tpayment: bcs.vector(SuiObjectRef),\n\towner: Address,\n\tprice: bcs.u64(),\n\tbudget: bcs.u64(),\n});\n\nexport const IntentScope = bcs.enum('IntentScope', {\n\tTransactionData: null,\n\tTransactionEffects: null,\n\tCheckpointSummary: null,\n\tPersonalMessage: null,\n});\n\nexport const IntentVersion = bcs.enum('IntentVersion', {\n\tV0: null,\n});\n\nexport const AppId = bcs.enum('AppId', {\n\tSui: null,\n});\n\nexport const Intent = bcs.struct('Intent', {\n\tscope: IntentScope,\n\tversion: IntentVersion,\n\tappId: AppId,\n});\n\nexport function IntentMessage<T extends BcsType<any>>(T: T) {\n\treturn bcs.struct(`IntentMessage<${T.name}>`, {\n\t\tintent: Intent,\n\t\tvalue: T,\n\t});\n}\n\nexport const CompressedSignature = bcs.enum('CompressedSignature', {\n\tED25519: bcs.bytes(64),\n\tSecp256k1: bcs.bytes(64),\n\tSecp256r1: bcs.bytes(64),\n\tZkLogin: bcs.byteVector(),\n\tPasskey: bcs.byteVector(),\n\tMLDSA65: bcs.bytes(3309),\n});\n\n// Variant order must match Sui's `PublicKey` enum, which validators hash to\n// derive a multisig address.\nexport const PublicKey = bcs.enum('PublicKey', {\n\tED25519: bcs.bytes(32),\n\tSecp256k1: bcs.bytes(33),\n\tSecp256r1: bcs.bytes(33),\n\tZkLogin: bcs.byteVector(),\n\tPasskey: bcs.bytes(33),\n\tMLDSA65: bcs.bytes(1952),\n});\n\nexport const MultiSigPkMap = bcs.struct('MultiSigPkMap', {\n\tpubKey: PublicKey,\n\tweight: bcs.u8(),\n});\n\nexport const MultiSigPublicKey = bcs.struct('MultiSigPublicKey', {\n\tpk_map: bcs.vector(MultiSigPkMap),\n\tthreshold: bcs.u16(),\n});\n\nexport const MultiSig = bcs.struct('MultiSig', {\n\tsigs: bcs.vector(CompressedSignature),\n\tbitmap: bcs.u16(),\n\tmultisig_pk: MultiSigPublicKey,\n});\n\nexport const base64String = bcs.byteVector().transform({\n\tinput: (val: string | Uint8Array) => (typeof val === 'string' ? fromBase64(val) : val),\n\toutput: (val) => toBase64(val),\n});\n\nexport const PasskeyAuthenticator = bcs.struct('PasskeyAuthenticator', {\n\tauthenticatorData: bcs.byteVector(),\n\tclientDataJson: bcs.string(),\n\tuserSignature: bcs.byteVector(),\n});\n\n// Rust: crates/sui-types/src/object.rs\nexport const MoveObjectType = bcs.enum('MoveObjectType', {\n\tOther: StructTag,\n\tGasCoin: null,\n\tStakedSui: null,\n\tCoin: TypeTag,\n\tAccumulatorBalanceWrapper: null,\n});\n\n// Rust: crates/sui-types/src/object.rs\nexport const TypeOrigin = bcs.struct('TypeOrigin', {\n\tmoduleName: bcs.string(),\n\tdatatypeName: bcs.string(),\n\tpackage: Address,\n});\n\n// Rust: crates/sui-types/src/object.rs\nexport const UpgradeInfo = bcs.struct('UpgradeInfo', {\n\tupgradedId: Address,\n\tupgradedVersion: bcs.u64(),\n});\n\n// Rust: crates/sui-types/src/object.rs\nexport const MovePackage = bcs.struct('MovePackage', {\n\tid: Address,\n\tversion: bcs.u64(),\n\tmoduleMap: bcs.map(bcs.string(), bcs.byteVector()),\n\ttypeOriginTable: bcs.vector(TypeOrigin),\n\tlinkageTable: bcs.map(Address, UpgradeInfo),\n});\n\n// Rust: crates/sui-types/src/object.rs\nexport const MoveObject = bcs.struct('MoveObject', {\n\ttype: MoveObjectType,\n\thasPublicTransfer: bcs.bool(),\n\tversion: bcs.u64(),\n\tcontents: bcs.byteVector(),\n});\n\n// Rust: crates/sui-types/src/object.rs\nexport const Data = bcs.enum('Data', {\n\tMove: MoveObject,\n\tPackage: MovePackage,\n});\n\n// Rust: crates/sui-types/src/object.rs\nexport const ObjectInner = bcs.struct('ObjectInner', {\n\tdata: Data,\n\towner: Owner,\n\tpreviousTransaction: ObjectDigest,\n\tstorageRebate: bcs.u64(),\n});\n"],"mappings":";;;;;AAUA,SAAS,WAAW,SAAkC;AACrD,QAAO,IACL,IAAI;EACJ,MAAM;EACN,GAAI;EACJ,CAAC,CACD,UAAU;EACV,QAAQ,QAAyB;EACjC,SAAS,QAAQ,OAAO,IAAI;EAC5B,CAAC;;AAGJ,SAAS,WAAwC,MAAS;AACzD,QAAO,IAAI,KAAK,UAAU;EACzB,MAAM;EACN,MAAM;EACN,CAAC;;AAGH,MAAM,cAAc,IAAI,UAAU,IAAI,CAAC,KAAK,GAAG;AAC/C,KAAK,IAAI,IAAI,GAAG,IAAI,IAAI,KAAK;AA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AM;CACN,2BAA2B;CAC3B,CAAC;AAGF,MAAa,aAAa,IAAI,OAAO,cAAc;CAClD,YAAY,IAAI,QAAQ;CACxB,cAAc,IAAI,QAAQ;CAC1B,SAAS;CACT,CAAC;AAGF,MAAa,cAAc,IAAI,OAAO,eAAe;CACpD,YAAY;CACZ,iBAAiB,IAAI,KAAK;CAC1B,CAAC;AAGF,MAAa,cAAc,IAAI,OAAO,eAAe;CACpD,IAAI;CACJ,SAAS,IAAI,KAAK;CAClB,WAAW,IAAI,IAAI,IAAI,QAAQ,EAAE,IAAI,YAAY,CAAC;CAClD,iBAAiB,IAAI,OAAO,WAAW;CACvC,cAAc,IAAI,IAAI,SAAS,YAAY;CAC3C,CAAC;AAGF,MAAa,aAAa,IAAI,OAAO,cAAc;CAClD,MAAM;CACN,mBAAmB,IAAI,MAAM;CAC7B,SAAS,IAAI,KAAK;CAClB,UAAU,IAAI,YAAY;CAC1B,CAAC;AAGF,MAAa,OAAO,IAAI,KAAK,QAAQ;CACpC,MAAM;CACN,SAAS;CACT,CAAC;AAGF,MAAa,cAAc,IAAI,OAAO,eAAe;CACpD,MAAM;CACN,OAAO;CACP,qBAAqB;CACrB,eAAe,IAAI,KAAK;CACxB,CAAC"}
|
|
@@ -2,9 +2,12 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* Parse and validate a path that is compliant to SLIP-0010 in form m/44'/784'/{account_index}'/{change_index}'/{address_index}'.
|
|
4
4
|
*
|
|
5
|
+
* The purpose node distinguishes signature schemes: 44 for Ed25519 (the default) and 94 for ML-DSA-65.
|
|
6
|
+
*
|
|
5
7
|
* @param path path string (e.g. `m/44'/784'/0'/0'/0'`).
|
|
8
|
+
* @param purpose purpose node of the scheme, defaults to 44.
|
|
6
9
|
*/
|
|
7
|
-
declare function isValidHardenedPath(path: string): boolean;
|
|
10
|
+
declare function isValidHardenedPath(path: string, purpose?: number): boolean;
|
|
8
11
|
/**
|
|
9
12
|
* Parse and validate a path that is compliant to BIP-32 in form m/54'/784'/{account_index}'/{change_index}/{address_index}
|
|
10
13
|
* for Secp256k1 and m/74'/784'/{account_index}'/{change_index}/{address_index} for Secp256r1.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mnemonics.d.mts","names":[],"sources":["../../src/cryptography/mnemonics.ts"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"mnemonics.d.mts","names":[],"sources":["../../src/cryptography/mnemonics.ts"],"mappings":";;AAaA;;;;;AAeA;;iBAfgB,mBAAA,CAAoB,IAAA,UAAc,OAAA;;;AA2BlD;;;;;AASA;iBArBgB,gBAAA,CAAiB,IAAA;;;;;;iBAYjB,cAAA,CAAe,SAAA,WAAoB,UAAA;;;;;;iBASnC,iBAAA,CAAkB,SAAA"}
|
|
@@ -5,10 +5,13 @@ import { mnemonicToSeedSync } from "@scure/bip39";
|
|
|
5
5
|
/**
|
|
6
6
|
* Parse and validate a path that is compliant to SLIP-0010 in form m/44'/784'/{account_index}'/{change_index}'/{address_index}'.
|
|
7
7
|
*
|
|
8
|
+
* The purpose node distinguishes signature schemes: 44 for Ed25519 (the default) and 94 for ML-DSA-65.
|
|
9
|
+
*
|
|
8
10
|
* @param path path string (e.g. `m/44'/784'/0'/0'/0'`).
|
|
11
|
+
* @param purpose purpose node of the scheme, defaults to 44.
|
|
9
12
|
*/
|
|
10
|
-
function isValidHardenedPath(path) {
|
|
11
|
-
if (!(/* @__PURE__ */ new RegExp(
|
|
13
|
+
function isValidHardenedPath(path, purpose = 44) {
|
|
14
|
+
if (!(/* @__PURE__ */ new RegExp(`^m\\/${purpose}'\\/784'\\/[0-9]+'\\/[0-9]+'\\/[0-9]+'+$`)).test(path)) return false;
|
|
12
15
|
return true;
|
|
13
16
|
}
|
|
14
17
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mnemonics.mjs","names":["bip39MnemonicToSeedSync"],"sources":["../../src/cryptography/mnemonics.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\nimport { toHex } from '@mysten/bcs';\nimport { mnemonicToSeedSync as bip39MnemonicToSeedSync } from '@scure/bip39';\n\n/**\n * Parse and validate a path that is compliant to SLIP-0010 in form m/44'/784'/{account_index}'/{change_index}'/{address_index}'.\n *\n * @param path path string (e.g. `m/44'/784'/0'/0'/0'`).\n */\nexport function isValidHardenedPath(path: string): boolean {\n\tif (!new RegExp(
|
|
1
|
+
{"version":3,"file":"mnemonics.mjs","names":["bip39MnemonicToSeedSync"],"sources":["../../src/cryptography/mnemonics.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\nimport { toHex } from '@mysten/bcs';\nimport { mnemonicToSeedSync as bip39MnemonicToSeedSync } from '@scure/bip39';\n\n/**\n * Parse and validate a path that is compliant to SLIP-0010 in form m/44'/784'/{account_index}'/{change_index}'/{address_index}'.\n *\n * The purpose node distinguishes signature schemes: 44 for Ed25519 (the default) and 94 for ML-DSA-65.\n *\n * @param path path string (e.g. `m/44'/784'/0'/0'/0'`).\n * @param purpose purpose node of the scheme, defaults to 44.\n */\nexport function isValidHardenedPath(path: string, purpose = 44): boolean {\n\tif (!new RegExp(`^m\\\\/${purpose}'\\\\/784'\\\\/[0-9]+'\\\\/[0-9]+'\\\\/[0-9]+'+$`).test(path)) {\n\t\treturn false;\n\t}\n\treturn true;\n}\n\n/**\n * Parse and validate a path that is compliant to BIP-32 in form m/54'/784'/{account_index}'/{change_index}/{address_index}\n * for Secp256k1 and m/74'/784'/{account_index}'/{change_index}/{address_index} for Secp256r1.\n *\n * Note that the purpose for Secp256k1 is registered as 54, to differentiate from Ed25519 with purpose 44.\n *\n * @param path path string (e.g. `m/54'/784'/0'/0/0`).\n */\nexport function isValidBIP32Path(path: string): boolean {\n\tif (!new RegExp(\"^m\\\\/(54|74)'\\\\/784'\\\\/[0-9]+'\\\\/[0-9]+\\\\/[0-9]+$\").test(path)) {\n\t\treturn false;\n\t}\n\treturn true;\n}\n\n/**\n * Uses KDF to derive 64 bytes of key data from mnemonic with empty password.\n *\n * @param mnemonics 12 words string split by spaces.\n */\nexport function mnemonicToSeed(mnemonics: string): Uint8Array {\n\treturn bip39MnemonicToSeedSync(mnemonics, '');\n}\n\n/**\n * Derive the seed in hex format from a 12-word mnemonic string.\n *\n * @param mnemonics 12 words string split by spaces.\n */\nexport function mnemonicToSeedHex(mnemonics: string): string {\n\treturn toHex(mnemonicToSeed(mnemonics));\n}\n"],"mappings":";;;;;;;;;;;;AAaA,SAAgB,oBAAoB,MAAc,UAAU,IAAa;AACxE,KAAI,kBAAC,IAAI,OAAO,QAAQ,QAAQ,0CAA0C,EAAC,KAAK,KAAK,CACpF,QAAO;AAER,QAAO;;;;;;;;;;AAWR,SAAgB,iBAAiB,MAAuB;AACvD,KAAI,kBAAC,IAAI,OAAO,oDAAoD,EAAC,KAAK,KAAK,CAC9E,QAAO;AAER,QAAO;;;;;;;AAQR,SAAgB,eAAe,WAA+B;AAC7D,QAAOA,mBAAwB,WAAW,GAAG;;;;;;;AAQ9C,SAAgB,kBAAkB,WAA2B;AAC5D,QAAO,MAAM,eAAe,UAAU,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"slip10.d.mts","names":[],"sources":["../../src/cryptography/slip10.ts"],"mappings":";cAgBa,yBAAA"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { sha512 } from "@noble/hashes/sha2.js";
|
|
2
|
+
import { hmac } from "@noble/hashes/hmac.js";
|
|
3
|
+
|
|
4
|
+
//#region src/cryptography/slip10.ts
|
|
5
|
+
const ED25519_SLIP10_MASTER_KEY = "ed25519 seed";
|
|
6
|
+
const MLDSA65_SLIP10_MASTER_KEY = "ML-DSA-65 seed";
|
|
7
|
+
const HARDENED_OFFSET = 2147483648;
|
|
8
|
+
const MIN_SEED_LENGTH = 16;
|
|
9
|
+
const MAX_SEED_LENGTH = 64;
|
|
10
|
+
const pathRegex = /^m(\/(0|[1-9][0-9]*)')+$/;
|
|
11
|
+
const getMasterKeyFromSeed = (masterKey, seed) => {
|
|
12
|
+
return split(hmac(sha512, new TextEncoder().encode(masterKey), seed));
|
|
13
|
+
};
|
|
14
|
+
const CKDPriv = ({ key, chainCode }, index) => {
|
|
15
|
+
const data = new Uint8Array(1 + key.length + 4);
|
|
16
|
+
data.set(key, 1);
|
|
17
|
+
new DataView(data.buffer).setUint32(1 + key.length, index);
|
|
18
|
+
const I = hmac(sha512, chainCode, data);
|
|
19
|
+
data.fill(0);
|
|
20
|
+
return split(I);
|
|
21
|
+
};
|
|
22
|
+
const split = (I) => {
|
|
23
|
+
const node = {
|
|
24
|
+
key: I.slice(0, 32),
|
|
25
|
+
chainCode: I.slice(32)
|
|
26
|
+
};
|
|
27
|
+
I.fill(0);
|
|
28
|
+
return node;
|
|
29
|
+
};
|
|
30
|
+
const wipe = ({ key, chainCode }) => {
|
|
31
|
+
key.fill(0);
|
|
32
|
+
chainCode.fill(0);
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Derive the SLIP-0010 node at `path` from `seed` under `masterKey`. Every level must be
|
|
36
|
+
* hardened; neither scheme has public derivation. The node secret at the end of the path
|
|
37
|
+
* is the Ed25519 private key or the FIPS 204 keygen seed.
|
|
38
|
+
*/
|
|
39
|
+
const derivePath = (masterKey, path, seed) => {
|
|
40
|
+
if (!pathRegex.test(path)) throw new Error("Invalid derivation path");
|
|
41
|
+
if (seed.length < MIN_SEED_LENGTH || seed.length > MAX_SEED_LENGTH) throw new Error(`Invalid seed length: expected ${MIN_SEED_LENGTH} to ${MAX_SEED_LENGTH} bytes`);
|
|
42
|
+
const segments = path.split("/").slice(1).map((el) => parseInt(el.slice(0, -1), 10));
|
|
43
|
+
if (segments.some((segment) => segment >= HARDENED_OFFSET)) throw new Error("Invalid derivation path");
|
|
44
|
+
let node = getMasterKeyFromSeed(masterKey, seed);
|
|
45
|
+
for (const segment of segments) {
|
|
46
|
+
const child = CKDPriv(node, (segment | HARDENED_OFFSET) >>> 0);
|
|
47
|
+
wipe(node);
|
|
48
|
+
node = child;
|
|
49
|
+
}
|
|
50
|
+
return node;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
//#endregion
|
|
54
|
+
export { ED25519_SLIP10_MASTER_KEY, MLDSA65_SLIP10_MASTER_KEY, derivePath };
|
|
55
|
+
//# sourceMappingURL=slip10.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"slip10.mjs","names":[],"sources":["../../src/cryptography/slip10.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\n// SLIP-0010 hardened derivation for Ed25519 and ML-DSA-65. The master key string picks\n// the tree; the HMAC-SHA512 walk below it is the same. Mirrors `fastcrypto::slip10`.\n\nimport { hmac } from '@noble/hashes/hmac.js';\nimport { sha512 } from '@noble/hashes/sha2.js';\n\nexport type Slip10Node = {\n\tkey: Uint8Array;\n\tchainCode: Uint8Array;\n};\n\nexport const ED25519_SLIP10_MASTER_KEY = 'ed25519 seed';\n// Proposed in https://github.com/satoshilabs/slips/pull/1968.\nexport const MLDSA65_SLIP10_MASTER_KEY = 'ML-DSA-65 seed';\n\nconst HARDENED_OFFSET = 0x80000000;\n\n// SLIP-0010 seeds are 128 to 512 bits.\nconst MIN_SEED_LENGTH = 16;\nconst MAX_SEED_LENGTH = 64;\n\n// Canonical decimal indices only; the range is checked in `derivePath`.\nconst pathRegex = /^m(\\/(0|[1-9][0-9]*)')+$/;\n\nconst getMasterKeyFromSeed = (masterKey: string, seed: Uint8Array): Slip10Node => {\n\tconst I = hmac(sha512, new TextEncoder().encode(masterKey), seed);\n\treturn split(I);\n};\n\nconst CKDPriv = ({ key, chainCode }: Slip10Node, index: number): Slip10Node => {\n\tconst data = new Uint8Array(1 + key.length + 4);\n\tdata.set(key, 1);\n\tnew DataView(data.buffer).setUint32(1 + key.length, index);\n\n\tconst I = hmac(sha512, chainCode, data);\n\tdata.fill(0);\n\treturn split(I);\n};\n\n// Copies the halves out and wipes the HMAC output, so no node secret outlives its use.\nconst split = (I: Uint8Array): Slip10Node => {\n\tconst node = { key: I.slice(0, 32), chainCode: I.slice(32) };\n\tI.fill(0);\n\treturn node;\n};\n\nconst wipe = ({ key, chainCode }: Slip10Node) => {\n\tkey.fill(0);\n\tchainCode.fill(0);\n};\n\n/**\n * Derive the SLIP-0010 node at `path` from `seed` under `masterKey`. Every level must be\n * hardened; neither scheme has public derivation. The node secret at the end of the path\n * is the Ed25519 private key or the FIPS 204 keygen seed.\n */\nexport const derivePath = (masterKey: string, path: string, seed: Uint8Array): Slip10Node => {\n\tif (!pathRegex.test(path)) {\n\t\tthrow new Error('Invalid derivation path');\n\t}\n\tif (seed.length < MIN_SEED_LENGTH || seed.length > MAX_SEED_LENGTH) {\n\t\tthrow new Error(`Invalid seed length: expected ${MIN_SEED_LENGTH} to ${MAX_SEED_LENGTH} bytes`);\n\t}\n\n\tconst segments = path\n\t\t.split('/')\n\t\t.slice(1)\n\t\t.map((el) => parseInt(el.slice(0, -1), 10));\n\t// An index of 2^31 or more would collide with a hardened index after the OR below.\n\tif (segments.some((segment) => segment >= HARDENED_OFFSET)) {\n\t\tthrow new Error('Invalid derivation path');\n\t}\n\n\tlet node = getMasterKeyFromSeed(masterKey, seed);\n\tfor (const segment of segments) {\n\t\tconst child = CKDPriv(node, (segment | HARDENED_OFFSET) >>> 0);\n\t\twipe(node);\n\t\tnode = child;\n\t}\n\treturn node;\n};\n"],"mappings":";;;;AAcA,MAAa,4BAA4B;AAEzC,MAAa,4BAA4B;AAEzC,MAAM,kBAAkB;AAGxB,MAAM,kBAAkB;AACxB,MAAM,kBAAkB;AAGxB,MAAM,YAAY;AAElB,MAAM,wBAAwB,WAAmB,SAAiC;AAEjF,QAAO,MADG,KAAK,QAAQ,IAAI,aAAa,CAAC,OAAO,UAAU,EAAE,KAAK,CAClD;;AAGhB,MAAM,WAAW,EAAE,KAAK,aAAyB,UAA8B;CAC9E,MAAM,OAAO,IAAI,WAAW,IAAI,IAAI,SAAS,EAAE;AAC/C,MAAK,IAAI,KAAK,EAAE;AAChB,KAAI,SAAS,KAAK,OAAO,CAAC,UAAU,IAAI,IAAI,QAAQ,MAAM;CAE1D,MAAM,IAAI,KAAK,QAAQ,WAAW,KAAK;AACvC,MAAK,KAAK,EAAE;AACZ,QAAO,MAAM,EAAE;;AAIhB,MAAM,SAAS,MAA8B;CAC5C,MAAM,OAAO;EAAE,KAAK,EAAE,MAAM,GAAG,GAAG;EAAE,WAAW,EAAE,MAAM,GAAG;EAAE;AAC5D,GAAE,KAAK,EAAE;AACT,QAAO;;AAGR,MAAM,QAAQ,EAAE,KAAK,gBAA4B;AAChD,KAAI,KAAK,EAAE;AACX,WAAU,KAAK,EAAE;;;;;;;AAQlB,MAAa,cAAc,WAAmB,MAAc,SAAiC;AAC5F,KAAI,CAAC,UAAU,KAAK,KAAK,CACxB,OAAM,IAAI,MAAM,0BAA0B;AAE3C,KAAI,KAAK,SAAS,mBAAmB,KAAK,SAAS,gBAClD,OAAM,IAAI,MAAM,iCAAiC,gBAAgB,MAAM,gBAAgB,QAAQ;CAGhG,MAAM,WAAW,KACf,MAAM,IAAI,CACV,MAAM,EAAE,CACR,KAAK,OAAO,SAAS,GAAG,MAAM,GAAG,GAAG,EAAE,GAAG,CAAC;AAE5C,KAAI,SAAS,MAAM,YAAY,WAAW,gBAAgB,CACzD,OAAM,IAAI,MAAM,0BAA0B;CAG3C,IAAI,OAAO,qBAAqB,WAAW,KAAK;AAChD,MAAK,MAAM,WAAW,UAAU;EAC/B,MAAM,QAAQ,QAAQ,OAAO,UAAU,qBAAqB,EAAE;AAC9D,OAAK,KAAK;AACV,SAAO;;AAER,QAAO"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AdvanceCheckpointRequest, AdvanceCheckpointResponse, AdvanceClockRequest, AdvanceClockResponse, GetStatusRequest, GetStatusResponse } from "./forking_service.mjs";
|
|
2
|
-
import * as
|
|
3
|
-
import * as
|
|
2
|
+
import * as _protobuf_ts_runtime6 from "@protobuf-ts/runtime";
|
|
3
|
+
import * as _protobuf_ts_runtime_rpc6 from "@protobuf-ts/runtime-rpc";
|
|
4
4
|
import { RpcOptions, RpcTransport, ServiceInfo, UnaryCall } from "@protobuf-ts/runtime-rpc";
|
|
5
5
|
|
|
6
6
|
//#region src/grpc/proto/sui/forking/v1alpha/forking_service.client.d.ts
|
|
@@ -37,9 +37,9 @@ interface IForkingServiceClient {
|
|
|
37
37
|
declare class ForkingServiceClient implements IForkingServiceClient, ServiceInfo {
|
|
38
38
|
private readonly _transport;
|
|
39
39
|
typeName: string;
|
|
40
|
-
methods:
|
|
40
|
+
methods: _protobuf_ts_runtime_rpc6.MethodInfo<any, any>[];
|
|
41
41
|
options: {
|
|
42
|
-
[extensionName: string]:
|
|
42
|
+
[extensionName: string]: _protobuf_ts_runtime6.JsonValue;
|
|
43
43
|
};
|
|
44
44
|
constructor(_transport: RpcTransport);
|
|
45
45
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BatchGetObjectsRequest, BatchGetObjectsResponse, BatchGetTransactionsRequest, BatchGetTransactionsResponse, GetCheckpointRequest, GetCheckpointResponse, GetEpochRequest, GetEpochResponse, GetObjectRequest, GetObjectResponse, GetServiceInfoRequest, GetServiceInfoResponse, GetTransactionRequest, GetTransactionResponse, ListCheckpointsRequest, ListCheckpointsResponse, ListEventsRequest, ListEventsResponse, ListTransactionsRequest, ListTransactionsResponse } from "./ledger_service.mjs";
|
|
2
|
-
import * as
|
|
3
|
-
import * as
|
|
2
|
+
import * as _protobuf_ts_runtime2 from "@protobuf-ts/runtime";
|
|
3
|
+
import * as _protobuf_ts_runtime_rpc2 from "@protobuf-ts/runtime-rpc";
|
|
4
4
|
import { RpcOptions, RpcTransport, ServerStreamingCall, ServiceInfo, UnaryCall } from "@protobuf-ts/runtime-rpc";
|
|
5
5
|
|
|
6
6
|
//#region src/grpc/proto/sui/rpc/v2/ledger_service.client.d.ts
|
|
@@ -73,9 +73,9 @@ interface ILedgerServiceClient {
|
|
|
73
73
|
declare class LedgerServiceClient implements ILedgerServiceClient, ServiceInfo {
|
|
74
74
|
private readonly _transport;
|
|
75
75
|
typeName: string;
|
|
76
|
-
methods:
|
|
76
|
+
methods: _protobuf_ts_runtime_rpc2.MethodInfo<any, any>[];
|
|
77
77
|
options: {
|
|
78
|
-
[extensionName: string]:
|
|
78
|
+
[extensionName: string]: _protobuf_ts_runtime2.JsonValue;
|
|
79
79
|
};
|
|
80
80
|
constructor(_transport: RpcTransport);
|
|
81
81
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { GetDatatypeRequest, GetDatatypeResponse, GetFunctionRequest, GetFunctionResponse, GetPackageRequest, GetPackageResponse, ListPackageVersionsRequest, ListPackageVersionsResponse } from "./move_package_service.mjs";
|
|
2
|
-
import * as
|
|
3
|
-
import * as
|
|
2
|
+
import * as _protobuf_ts_runtime0 from "@protobuf-ts/runtime";
|
|
3
|
+
import * as _protobuf_ts_runtime_rpc0 from "@protobuf-ts/runtime-rpc";
|
|
4
4
|
import { RpcOptions, RpcTransport, ServiceInfo, UnaryCall } from "@protobuf-ts/runtime-rpc";
|
|
5
5
|
|
|
6
6
|
//#region src/grpc/proto/sui/rpc/v2/move_package_service.client.d.ts
|
|
@@ -31,9 +31,9 @@ interface IMovePackageServiceClient {
|
|
|
31
31
|
declare class MovePackageServiceClient implements IMovePackageServiceClient, ServiceInfo {
|
|
32
32
|
private readonly _transport;
|
|
33
33
|
typeName: string;
|
|
34
|
-
methods:
|
|
34
|
+
methods: _protobuf_ts_runtime_rpc0.MethodInfo<any, any>[];
|
|
35
35
|
options: {
|
|
36
|
-
[extensionName: string]:
|
|
36
|
+
[extensionName: string]: _protobuf_ts_runtime0.JsonValue;
|
|
37
37
|
};
|
|
38
38
|
constructor(_transport: RpcTransport);
|
|
39
39
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { VerifySignatureRequest, VerifySignatureResponse } from "./signature_verification_service.mjs";
|
|
2
|
-
import * as
|
|
3
|
-
import * as
|
|
2
|
+
import * as _protobuf_ts_runtime0 from "@protobuf-ts/runtime";
|
|
3
|
+
import * as _protobuf_ts_runtime_rpc0 from "@protobuf-ts/runtime-rpc";
|
|
4
4
|
import { RpcOptions, RpcTransport, ServiceInfo, UnaryCall } from "@protobuf-ts/runtime-rpc";
|
|
5
5
|
|
|
6
6
|
//#region src/grpc/proto/sui/rpc/v2/signature_verification_service.client.d.ts
|
|
@@ -21,9 +21,9 @@ interface ISignatureVerificationServiceClient {
|
|
|
21
21
|
declare class SignatureVerificationServiceClient implements ISignatureVerificationServiceClient, ServiceInfo {
|
|
22
22
|
private readonly _transport;
|
|
23
23
|
typeName: string;
|
|
24
|
-
methods:
|
|
24
|
+
methods: _protobuf_ts_runtime_rpc0.MethodInfo<any, any>[];
|
|
25
25
|
options: {
|
|
26
|
-
[extensionName: string]:
|
|
26
|
+
[extensionName: string]: _protobuf_ts_runtime0.JsonValue;
|
|
27
27
|
};
|
|
28
28
|
constructor(_transport: RpcTransport);
|
|
29
29
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { GetBalanceRequest, GetBalanceResponse, GetCoinInfoRequest, GetCoinInfoResponse, ListBalancesRequest, ListBalancesResponse, ListDynamicFieldsRequest, ListDynamicFieldsResponse, ListOwnedObjectsRequest, ListOwnedObjectsResponse } from "./state_service.mjs";
|
|
2
|
-
import * as
|
|
3
|
-
import * as
|
|
2
|
+
import * as _protobuf_ts_runtime3 from "@protobuf-ts/runtime";
|
|
3
|
+
import * as _protobuf_ts_runtime_rpc3 from "@protobuf-ts/runtime-rpc";
|
|
4
4
|
import { RpcOptions, RpcTransport, ServiceInfo, UnaryCall } from "@protobuf-ts/runtime-rpc";
|
|
5
5
|
|
|
6
6
|
//#region src/grpc/proto/sui/rpc/v2/state_service.client.d.ts
|
|
@@ -35,9 +35,9 @@ interface IStateServiceClient {
|
|
|
35
35
|
declare class StateServiceClient implements IStateServiceClient, ServiceInfo {
|
|
36
36
|
private readonly _transport;
|
|
37
37
|
typeName: string;
|
|
38
|
-
methods:
|
|
38
|
+
methods: _protobuf_ts_runtime_rpc3.MethodInfo<any, any>[];
|
|
39
39
|
options: {
|
|
40
|
-
[extensionName: string]:
|
|
40
|
+
[extensionName: string]: _protobuf_ts_runtime3.JsonValue;
|
|
41
41
|
};
|
|
42
42
|
constructor(_transport: RpcTransport);
|
|
43
43
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SubscribeCheckpointsRequest, SubscribeCheckpointsResponse, SubscribeEventsRequest, SubscribeEventsResponse, SubscribeTransactionsRequest, SubscribeTransactionsResponse } from "./subscription_service.mjs";
|
|
2
|
-
import * as
|
|
3
|
-
import * as
|
|
2
|
+
import * as _protobuf_ts_runtime1 from "@protobuf-ts/runtime";
|
|
3
|
+
import * as _protobuf_ts_runtime_rpc1 from "@protobuf-ts/runtime-rpc";
|
|
4
4
|
import { RpcOptions, RpcTransport, ServerStreamingCall, ServiceInfo } from "@protobuf-ts/runtime-rpc";
|
|
5
5
|
|
|
6
6
|
//#region src/grpc/proto/sui/rpc/v2/subscription_service.client.d.ts
|
|
@@ -100,9 +100,9 @@ interface ISubscriptionServiceClient {
|
|
|
100
100
|
declare class SubscriptionServiceClient implements ISubscriptionServiceClient, ServiceInfo {
|
|
101
101
|
private readonly _transport;
|
|
102
102
|
typeName: string;
|
|
103
|
-
methods:
|
|
103
|
+
methods: _protobuf_ts_runtime_rpc1.MethodInfo<any, any>[];
|
|
104
104
|
options: {
|
|
105
|
-
[extensionName: string]:
|
|
105
|
+
[extensionName: string]: _protobuf_ts_runtime1.JsonValue;
|
|
106
106
|
};
|
|
107
107
|
constructor(_transport: RpcTransport);
|
|
108
108
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ExecuteTransactionRequest, ExecuteTransactionResponse, SimulateTransactionRequest, SimulateTransactionResponse } from "./transaction_execution_service.mjs";
|
|
2
|
-
import * as
|
|
3
|
-
import * as
|
|
2
|
+
import * as _protobuf_ts_runtime4 from "@protobuf-ts/runtime";
|
|
3
|
+
import * as _protobuf_ts_runtime_rpc4 from "@protobuf-ts/runtime-rpc";
|
|
4
4
|
import { RpcOptions, RpcTransport, ServiceInfo, UnaryCall } from "@protobuf-ts/runtime-rpc";
|
|
5
5
|
|
|
6
6
|
//#region src/grpc/proto/sui/rpc/v2/transaction_execution_service.client.d.ts
|
|
@@ -23,9 +23,9 @@ interface ITransactionExecutionServiceClient {
|
|
|
23
23
|
declare class TransactionExecutionServiceClient implements ITransactionExecutionServiceClient, ServiceInfo {
|
|
24
24
|
private readonly _transport;
|
|
25
25
|
typeName: string;
|
|
26
|
-
methods:
|
|
26
|
+
methods: _protobuf_ts_runtime_rpc4.MethodInfo<any, any>[];
|
|
27
27
|
options: {
|
|
28
|
-
[extensionName: string]:
|
|
28
|
+
[extensionName: string]: _protobuf_ts_runtime4.JsonValue;
|
|
29
29
|
};
|
|
30
30
|
constructor(_transport: RpcTransport);
|
|
31
31
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keypair.d.mts","names":[],"sources":["../../../src/keypairs/ed25519/keypair.ts"],"mappings":";;;;;cAiBa,+BAAA;;AAAb;;;;UAOiB,kBAAA;EAChB,SAAA,EAAW,UAAA;EACX,SAAA,EAAW,UAAA;AAAA;;;;cAMC,cAAA,SAAuB,OAAA;EAAA,QAC3B,OAAA;EAPa;;AAMtB;;;;cASa,OAAA,GAAU,kBAAA;EA0BH;;;EAPnB,YAAA,CAAA,GAAgB,eAAA;EAiFC;;;EAAA,OA1EV,QAAA,CAAA,GAAY,cAAA;EAqFqC;;;;;;;;;;EAAA,OAnEjD,aAAA,CACN,SAAA,EAAW,UAAA,WACX,OAAA;IAAY,cAAA;EAAA,IACV,cAAA;EArBI;;;EAyDP,YAAA,CAAA,GAAgB,gBAAA;EAtCf;;;EA6CD,YAAA,CAAA;EAPA;;;EAiBM,IAAA,CAAK,IAAA,EAAM,UAAA,GAAU,OAAA,CAAA,UAAA,CAAA,WAAA;EAAV;;;;;;;EAAA,OAWV,aAAA,CAAc,SAAA,UAAmB,IAAA,YAAgB,cAAA;EAAA;;;;;;;;EAAA,
|
|
1
|
+
{"version":3,"file":"keypair.d.mts","names":[],"sources":["../../../src/keypairs/ed25519/keypair.ts"],"mappings":";;;;;cAiBa,+BAAA;;AAAb;;;;UAOiB,kBAAA;EAChB,SAAA,EAAW,UAAA;EACX,SAAA,EAAW,UAAA;AAAA;;;;cAMC,cAAA,SAAuB,OAAA;EAAA,QAC3B,OAAA;EAPa;;AAMtB;;;;cASa,OAAA,GAAU,kBAAA;EA0BH;;;EAPnB,YAAA,CAAA,GAAgB,eAAA;EAiFC;;;EAAA,OA1EV,QAAA,CAAA,GAAY,cAAA;EAqFqC;;;;;;;;;;EAAA,OAnEjD,aAAA,CACN,SAAA,EAAW,UAAA,WACX,OAAA;IAAY,cAAA;EAAA,IACV,cAAA;EArBI;;;EAyDP,YAAA,CAAA,GAAgB,gBAAA;EAtCf;;;EA6CD,YAAA,CAAA;EAPA;;;EAiBM,IAAA,CAAK,IAAA,EAAM,UAAA,GAAU,OAAA,CAAA,UAAA,CAAA,WAAA;EAAV;;;;;;;EAAA,OAWV,aAAA,CAAc,SAAA,UAAmB,IAAA,YAAgB,cAAA;EAAA;;;;;;;;EAAA,OAYjD,qBAAA,CAAsB,IAAA,WAAe,UAAA,EAAY,IAAA,YAAgB,cAAA;AAAA"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { isValidHardenedPath,
|
|
1
|
+
import { isValidHardenedPath, mnemonicToSeed } from "../../cryptography/mnemonics.mjs";
|
|
2
2
|
import { Keypair, PRIVATE_KEY_SIZE, decodeSuiPrivateKey, encodeSuiPrivateKey } from "../../cryptography/keypair.mjs";
|
|
3
|
-
import { derivePath } from "
|
|
3
|
+
import { ED25519_SLIP10_MASTER_KEY, derivePath } from "../../cryptography/slip10.mjs";
|
|
4
4
|
import { Ed25519PublicKey } from "./publickey.mjs";
|
|
5
|
-
import {
|
|
5
|
+
import { fromHex } from "@mysten/bcs";
|
|
6
6
|
import { ed25519 } from "@noble/curves/ed25519.js";
|
|
7
7
|
|
|
8
8
|
//#region src/keypairs/ed25519/keypair.ts
|
|
@@ -102,10 +102,7 @@ var Ed25519Keypair = class Ed25519Keypair extends Keypair {
|
|
|
102
102
|
* be compliant to SLIP-0010 in form m/44'/784'/{account_index}'/{change_index}'/{address_index}'.
|
|
103
103
|
*/
|
|
104
104
|
static deriveKeypair(mnemonics, path) {
|
|
105
|
-
|
|
106
|
-
if (!isValidHardenedPath(path)) throw new Error("Invalid derivation path");
|
|
107
|
-
const { key } = derivePath(path, mnemonicToSeedHex(mnemonics));
|
|
108
|
-
return Ed25519Keypair.fromSecretKey(key);
|
|
105
|
+
return Ed25519Keypair.deriveKeypairFromSeed(mnemonicToSeed(mnemonics), path);
|
|
109
106
|
}
|
|
110
107
|
/**
|
|
111
108
|
* Derive Ed25519 keypair from mnemonicSeed and path.
|
|
@@ -118,8 +115,8 @@ var Ed25519Keypair = class Ed25519Keypair extends Keypair {
|
|
|
118
115
|
static deriveKeypairFromSeed(seed, path) {
|
|
119
116
|
if (path == null) path = DEFAULT_ED25519_DERIVATION_PATH;
|
|
120
117
|
if (!isValidHardenedPath(path)) throw new Error("Invalid derivation path");
|
|
121
|
-
const
|
|
122
|
-
|
|
118
|
+
const { key, chainCode } = derivePath(ED25519_SLIP10_MASTER_KEY, path, typeof seed === "string" ? fromHex(seed) : seed);
|
|
119
|
+
chainCode.fill(0);
|
|
123
120
|
return Ed25519Keypair.fromSecretKey(key);
|
|
124
121
|
}
|
|
125
122
|
};
|