@mysten/sui 1.10.0 → 1.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.
Files changed (187) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/dist/cjs/bcs/bcs.js +14 -14
  3. package/dist/cjs/bcs/bcs.js.map +2 -2
  4. package/dist/cjs/client/client.js +6 -6
  5. package/dist/cjs/client/client.js.map +2 -2
  6. package/dist/cjs/client/types/generated.d.ts +1 -2
  7. package/dist/cjs/client/types/generated.js.map +1 -1
  8. package/dist/cjs/cryptography/keypair.js +2 -2
  9. package/dist/cjs/cryptography/keypair.js.map +2 -2
  10. package/dist/cjs/cryptography/mnemonics.js +1 -1
  11. package/dist/cjs/cryptography/mnemonics.js.map +1 -1
  12. package/dist/cjs/cryptography/publickey.js +2 -2
  13. package/dist/cjs/cryptography/publickey.js.map +2 -2
  14. package/dist/cjs/cryptography/signature.js +2 -2
  15. package/dist/cjs/cryptography/signature.js.map +2 -2
  16. package/dist/cjs/graphql/generated/2024.1/tada-env.d.js.map +1 -1
  17. package/dist/cjs/graphql/generated/2024.4/tada-env.d.js.map +1 -1
  18. package/dist/cjs/graphql/schemas/2024.1/index.d.ts +32 -0
  19. package/dist/cjs/graphql/schemas/2024.4/index.d.ts +63 -1
  20. package/dist/cjs/keypairs/ed25519/ed25519-hd-key.js +1 -1
  21. package/dist/cjs/keypairs/ed25519/ed25519-hd-key.js.map +1 -1
  22. package/dist/cjs/keypairs/ed25519/keypair.d.ts +2 -2
  23. package/dist/cjs/keypairs/ed25519/keypair.js +8 -1
  24. package/dist/cjs/keypairs/ed25519/keypair.js.map +2 -2
  25. package/dist/cjs/keypairs/ed25519/publickey.js +1 -1
  26. package/dist/cjs/keypairs/ed25519/publickey.js.map +2 -2
  27. package/dist/cjs/keypairs/secp256k1/keypair.d.ts +2 -2
  28. package/dist/cjs/keypairs/secp256k1/keypair.js +8 -1
  29. package/dist/cjs/keypairs/secp256k1/keypair.js.map +2 -2
  30. package/dist/cjs/keypairs/secp256k1/publickey.js +1 -1
  31. package/dist/cjs/keypairs/secp256k1/publickey.js.map +2 -2
  32. package/dist/cjs/keypairs/secp256r1/keypair.d.ts +2 -2
  33. package/dist/cjs/keypairs/secp256r1/keypair.js +8 -1
  34. package/dist/cjs/keypairs/secp256r1/keypair.js.map +2 -2
  35. package/dist/cjs/keypairs/secp256r1/publickey.js +1 -1
  36. package/dist/cjs/keypairs/secp256r1/publickey.js.map +2 -2
  37. package/dist/cjs/multisig/publickey.js +2 -2
  38. package/dist/cjs/multisig/publickey.js.map +2 -2
  39. package/dist/cjs/multisig/signer.js +2 -2
  40. package/dist/cjs/multisig/signer.js.map +2 -2
  41. package/dist/cjs/transactions/Commands.js +2 -2
  42. package/dist/cjs/transactions/Commands.js.map +2 -2
  43. package/dist/cjs/transactions/Inputs.js +1 -1
  44. package/dist/cjs/transactions/Inputs.js.map +2 -2
  45. package/dist/cjs/transactions/Transaction.js +2 -2
  46. package/dist/cjs/transactions/Transaction.js.map +2 -2
  47. package/dist/cjs/transactions/TransactionData.js +1 -1
  48. package/dist/cjs/transactions/TransactionData.js.map +2 -2
  49. package/dist/cjs/transactions/data/v1.js +6 -6
  50. package/dist/cjs/transactions/data/v1.js.map +2 -2
  51. package/dist/cjs/transactions/executor/parallel.js +1 -1
  52. package/dist/cjs/transactions/executor/parallel.js.map +2 -2
  53. package/dist/cjs/transactions/executor/serial.js +1 -1
  54. package/dist/cjs/transactions/executor/serial.js.map +2 -2
  55. package/dist/cjs/transactions/json-rpc-resolver.js +1 -1
  56. package/dist/cjs/transactions/json-rpc-resolver.js.map +1 -1
  57. package/dist/cjs/utils/dynamic-fields.d.ts +2 -0
  58. package/dist/cjs/utils/dynamic-fields.js +41 -0
  59. package/dist/cjs/utils/dynamic-fields.js.map +7 -0
  60. package/dist/cjs/utils/index.d.ts +2 -1
  61. package/dist/cjs/utils/index.js +9 -1
  62. package/dist/cjs/utils/index.js.map +2 -2
  63. package/dist/cjs/utils/sui-types.js +1 -1
  64. package/dist/cjs/utils/sui-types.js.map +2 -2
  65. package/dist/cjs/verify/verify.js +1 -1
  66. package/dist/cjs/verify/verify.js.map +2 -2
  67. package/dist/cjs/version.d.ts +2 -2
  68. package/dist/cjs/version.js +2 -2
  69. package/dist/cjs/version.js.map +1 -1
  70. package/dist/cjs/zklogin/publickey.js +5 -5
  71. package/dist/cjs/zklogin/publickey.js.map +2 -2
  72. package/dist/cjs/zklogin/signature.js +3 -3
  73. package/dist/cjs/zklogin/signature.js.map +2 -2
  74. package/dist/esm/bcs/bcs.js +15 -15
  75. package/dist/esm/bcs/bcs.js.map +2 -2
  76. package/dist/esm/client/client.js +7 -7
  77. package/dist/esm/client/client.js.map +2 -2
  78. package/dist/esm/client/types/generated.d.ts +1 -2
  79. package/dist/esm/cryptography/keypair.js +3 -3
  80. package/dist/esm/cryptography/keypair.js.map +2 -2
  81. package/dist/esm/cryptography/mnemonics.js +2 -2
  82. package/dist/esm/cryptography/mnemonics.js.map +1 -1
  83. package/dist/esm/cryptography/publickey.js +3 -3
  84. package/dist/esm/cryptography/publickey.js.map +2 -2
  85. package/dist/esm/cryptography/signature.js +3 -3
  86. package/dist/esm/cryptography/signature.js.map +2 -2
  87. package/dist/esm/graphql/schemas/2024.1/index.d.ts +32 -0
  88. package/dist/esm/graphql/schemas/2024.4/index.d.ts +63 -1
  89. package/dist/esm/keypairs/ed25519/ed25519-hd-key.js +2 -2
  90. package/dist/esm/keypairs/ed25519/ed25519-hd-key.js.map +1 -1
  91. package/dist/esm/keypairs/ed25519/keypair.d.ts +2 -2
  92. package/dist/esm/keypairs/ed25519/keypair.js +14 -2
  93. package/dist/esm/keypairs/ed25519/keypair.js.map +2 -2
  94. package/dist/esm/keypairs/ed25519/publickey.js +2 -2
  95. package/dist/esm/keypairs/ed25519/publickey.js.map +2 -2
  96. package/dist/esm/keypairs/secp256k1/keypair.d.ts +2 -2
  97. package/dist/esm/keypairs/secp256k1/keypair.js +9 -2
  98. package/dist/esm/keypairs/secp256k1/keypair.js.map +2 -2
  99. package/dist/esm/keypairs/secp256k1/publickey.js +2 -2
  100. package/dist/esm/keypairs/secp256k1/publickey.js.map +2 -2
  101. package/dist/esm/keypairs/secp256r1/keypair.d.ts +2 -2
  102. package/dist/esm/keypairs/secp256r1/keypair.js +9 -2
  103. package/dist/esm/keypairs/secp256r1/keypair.js.map +2 -2
  104. package/dist/esm/keypairs/secp256r1/publickey.js +2 -2
  105. package/dist/esm/keypairs/secp256r1/publickey.js.map +2 -2
  106. package/dist/esm/multisig/publickey.js +3 -3
  107. package/dist/esm/multisig/publickey.js.map +2 -2
  108. package/dist/esm/multisig/signer.js +3 -3
  109. package/dist/esm/multisig/signer.js.map +2 -2
  110. package/dist/esm/transactions/Commands.js +3 -3
  111. package/dist/esm/transactions/Commands.js.map +2 -2
  112. package/dist/esm/transactions/Inputs.js +2 -2
  113. package/dist/esm/transactions/Inputs.js.map +2 -2
  114. package/dist/esm/transactions/Transaction.js +3 -3
  115. package/dist/esm/transactions/Transaction.js.map +2 -2
  116. package/dist/esm/transactions/TransactionData.js +2 -2
  117. package/dist/esm/transactions/TransactionData.js.map +2 -2
  118. package/dist/esm/transactions/data/v1.js +7 -7
  119. package/dist/esm/transactions/data/v1.js.map +2 -2
  120. package/dist/esm/transactions/executor/parallel.js +2 -2
  121. package/dist/esm/transactions/executor/parallel.js.map +2 -2
  122. package/dist/esm/transactions/executor/serial.js +2 -2
  123. package/dist/esm/transactions/executor/serial.js.map +2 -2
  124. package/dist/esm/transactions/json-rpc-resolver.js +1 -1
  125. package/dist/esm/transactions/json-rpc-resolver.js.map +1 -1
  126. package/dist/esm/utils/dynamic-fields.d.ts +2 -0
  127. package/dist/esm/utils/dynamic-fields.js +21 -0
  128. package/dist/esm/utils/dynamic-fields.js.map +7 -0
  129. package/dist/esm/utils/index.d.ts +2 -1
  130. package/dist/esm/utils/index.js +21 -2
  131. package/dist/esm/utils/index.js.map +2 -2
  132. package/dist/esm/utils/sui-types.js +2 -2
  133. package/dist/esm/utils/sui-types.js.map +2 -2
  134. package/dist/esm/verify/verify.js +2 -2
  135. package/dist/esm/verify/verify.js.map +2 -2
  136. package/dist/esm/version.d.ts +2 -2
  137. package/dist/esm/version.js +2 -2
  138. package/dist/esm/version.js.map +1 -1
  139. package/dist/esm/zklogin/publickey.js +6 -6
  140. package/dist/esm/zklogin/publickey.js.map +2 -2
  141. package/dist/esm/zklogin/signature.js +4 -4
  142. package/dist/esm/zklogin/signature.js.map +2 -2
  143. package/dist/tsconfig.esm.tsbuildinfo +1 -1
  144. package/dist/tsconfig.tsbuildinfo +1 -1
  145. package/package.json +2 -2
  146. package/src/bcs/bcs.ts +15 -15
  147. package/src/client/client.ts +7 -7
  148. package/src/client/types/generated.ts +1 -2
  149. package/src/cryptography/keypair.ts +3 -3
  150. package/src/cryptography/mnemonics.ts +2 -2
  151. package/src/cryptography/publickey.ts +3 -3
  152. package/src/cryptography/signature.ts +3 -3
  153. package/src/graphql/generated/2024.1/schema.graphql +18 -4
  154. package/src/graphql/generated/2024.1/tada-env.d.ts +1 -1
  155. package/src/graphql/generated/2024.4/schema.graphql +33 -5
  156. package/src/graphql/generated/2024.4/tada-env.d.ts +3 -2
  157. package/src/keypairs/ed25519/ed25519-hd-key.ts +2 -2
  158. package/src/keypairs/ed25519/keypair.ts +18 -3
  159. package/src/keypairs/ed25519/publickey.ts +2 -2
  160. package/src/keypairs/secp256k1/keypair.ts +13 -3
  161. package/src/keypairs/secp256k1/publickey.ts +2 -2
  162. package/src/keypairs/secp256r1/keypair.ts +13 -3
  163. package/src/keypairs/secp256r1/publickey.ts +2 -2
  164. package/src/multisig/publickey.ts +3 -3
  165. package/src/multisig/signer.ts +3 -3
  166. package/src/transactions/Commands.ts +3 -3
  167. package/src/transactions/Inputs.ts +2 -2
  168. package/src/transactions/Transaction.ts +3 -3
  169. package/src/transactions/TransactionData.ts +2 -2
  170. package/src/transactions/__tests__/Transaction.test.ts +2 -2
  171. package/src/transactions/__tests__/bcs.test.ts +2 -2
  172. package/src/transactions/data/v1.ts +7 -7
  173. package/src/transactions/executor/parallel.ts +2 -2
  174. package/src/transactions/executor/serial.ts +2 -2
  175. package/src/transactions/json-rpc-resolver.ts +1 -1
  176. package/src/utils/dynamic-fields.ts +30 -0
  177. package/src/utils/index.ts +14 -1
  178. package/src/utils/sui-types.ts +2 -2
  179. package/src/verify/verify.ts +2 -2
  180. package/src/version.ts +2 -2
  181. package/src/zklogin/publickey.ts +6 -6
  182. package/src/zklogin/signature.ts +5 -4
  183. package/dist/cjs/graphql/generated/2024-01/tada-env.d.js +0 -17
  184. package/dist/cjs/graphql/generated/2024-01/tada-env.d.js.map +0 -7
  185. package/dist/esm/graphql/generated/2024-01/tada-env.d.js +0 -1
  186. package/dist/esm/graphql/generated/2024-01/tada-env.d.js.map +0 -7
  187. package/src/graphql/generated/2024-01/tada-env.d.ts +0 -202
package/src/bcs/bcs.ts CHANGED
@@ -2,7 +2,7 @@
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
4
  import type { BcsType, BcsTypeOptions } from '@mysten/bcs';
5
- import { bcs, fromB58, fromB64, fromHEX, toB58, toB64, toHEX } from '@mysten/bcs';
5
+ import { bcs, fromBase58, fromBase64, fromHex, toBase58, toBase64, toHex } from '@mysten/bcs';
6
6
 
7
7
  import { isValidSuiAddress, normalizeSuiAddress, SUI_ADDRESS_LENGTH } from '../utils/sui-types.js';
8
8
  import { TypeTagSerializer } from './type-tag-serializer.js';
@@ -29,22 +29,22 @@ function optionEnum<T extends BcsType<any, any>>(type: T) {
29
29
 
30
30
  export const Address = bcs.bytes(SUI_ADDRESS_LENGTH).transform({
31
31
  validate: (val) => {
32
- const address = typeof val === 'string' ? val : toHEX(val);
32
+ const address = typeof val === 'string' ? val : toHex(val);
33
33
  if (!address || !isValidSuiAddress(normalizeSuiAddress(address))) {
34
34
  throw new Error(`Invalid Sui address ${address}`);
35
35
  }
36
36
  },
37
37
  input: (val: string | Uint8Array) =>
38
- typeof val === 'string' ? fromHEX(normalizeSuiAddress(val)) : val,
39
- output: (val) => normalizeSuiAddress(toHEX(val)),
38
+ typeof val === 'string' ? fromHex(normalizeSuiAddress(val)) : val,
39
+ output: (val) => normalizeSuiAddress(toHex(val)),
40
40
  });
41
41
 
42
42
  export const ObjectDigest = bcs.vector(bcs.u8()).transform({
43
43
  name: 'ObjectDigest',
44
- input: (value: string) => fromB58(value),
45
- output: (value) => toB58(new Uint8Array(value)),
44
+ input: (value: string) => fromBase58(value),
45
+ output: (value) => toBase58(new Uint8Array(value)),
46
46
  validate: (value) => {
47
- if (fromB58(value).length !== 32) {
47
+ if (fromBase58(value).length !== 32) {
48
48
  throw new Error('ObjectDigest must be 32 bytes');
49
49
  }
50
50
  },
@@ -71,8 +71,8 @@ export const ObjectArg = bcs.enum('ObjectArg', {
71
71
  export const CallArg = bcs.enum('CallArg', {
72
72
  Pure: bcs.struct('Pure', {
73
73
  bytes: bcs.vector(bcs.u8()).transform({
74
- input: (val: string | Uint8Array) => (typeof val === 'string' ? fromB64(val) : val),
75
- output: (val) => toB64(new Uint8Array(val)),
74
+ input: (val: string | Uint8Array) => (typeof val === 'string' ? fromBase64(val) : val),
75
+ output: (val) => toBase64(new Uint8Array(val)),
76
76
  }),
77
77
  }),
78
78
  Object: ObjectArg,
@@ -147,8 +147,8 @@ export const Command = bcs.enum('Command', {
147
147
  Publish: bcs.struct('Publish', {
148
148
  modules: bcs.vector(
149
149
  bcs.vector(bcs.u8()).transform({
150
- input: (val: string | Uint8Array) => (typeof val === 'string' ? fromB64(val) : val),
151
- output: (val) => toB64(new Uint8Array(val)),
150
+ input: (val: string | Uint8Array) => (typeof val === 'string' ? fromBase64(val) : val),
151
+ output: (val) => toBase64(new Uint8Array(val)),
152
152
  }),
153
153
  ),
154
154
  dependencies: bcs.vector(Address),
@@ -175,8 +175,8 @@ export const Command = bcs.enum('Command', {
175
175
  Upgrade: bcs.struct('Upgrade', {
176
176
  modules: bcs.vector(
177
177
  bcs.vector(bcs.u8()).transform({
178
- input: (val: string | Uint8Array) => (typeof val === 'string' ? fromB64(val) : val),
179
- output: (val) => toB64(new Uint8Array(val)),
178
+ input: (val: string | Uint8Array) => (typeof val === 'string' ? fromBase64(val) : val),
179
+ output: (val) => toBase64(new Uint8Array(val)),
180
180
  }),
181
181
  ),
182
182
  dependencies: bcs.vector(Address),
@@ -286,8 +286,8 @@ export const MultiSig = bcs.struct('MultiSig', {
286
286
  });
287
287
 
288
288
  export const base64String = bcs.vector(bcs.u8()).transform({
289
- input: (val: string | Uint8Array) => (typeof val === 'string' ? fromB64(val) : val),
290
- output: (val) => toB64(new Uint8Array(val)),
289
+ input: (val: string | Uint8Array) => (typeof val === 'string' ? fromBase64(val) : val),
290
+ output: (val) => toBase64(new Uint8Array(val)),
291
291
  });
292
292
 
293
293
  export const SenderSignedTransaction = bcs.struct('SenderSignedTransaction', {
@@ -1,6 +1,6 @@
1
1
  // Copyright (c) Mysten Labs, Inc.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
- import { fromB58, toB64, toHEX } from '@mysten/bcs';
3
+ import { fromBase58, toBase64, toHex } from '@mysten/bcs';
4
4
 
5
5
  import type { Signer } from '../cryptography/index.js';
6
6
  import type { Transaction } from '../transactions/index.js';
@@ -415,7 +415,7 @@ export class SuiClient {
415
415
  const result: SuiTransactionBlockResponse = await this.transport.request({
416
416
  method: 'sui_executeTransactionBlock',
417
417
  params: [
418
- typeof transactionBlock === 'string' ? transactionBlock : toB64(transactionBlock),
418
+ typeof transactionBlock === 'string' ? transactionBlock : toBase64(transactionBlock),
419
419
  Array.isArray(signature) ? signature : [signature],
420
420
  options,
421
421
  ],
@@ -580,7 +580,7 @@ export class SuiClient {
580
580
  let devInspectTxBytes;
581
581
  if (isTransaction(input.transactionBlock)) {
582
582
  input.transactionBlock.setSenderIfNotSet(input.sender);
583
- devInspectTxBytes = toB64(
583
+ devInspectTxBytes = toBase64(
584
584
  await input.transactionBlock.build({
585
585
  client: this,
586
586
  onlyTransactionKind: true,
@@ -589,7 +589,7 @@ export class SuiClient {
589
589
  } else if (typeof input.transactionBlock === 'string') {
590
590
  devInspectTxBytes = input.transactionBlock;
591
591
  } else if (input.transactionBlock instanceof Uint8Array) {
592
- devInspectTxBytes = toB64(input.transactionBlock);
592
+ devInspectTxBytes = toBase64(input.transactionBlock);
593
593
  } else {
594
594
  throw new Error('Unknown transaction block format.');
595
595
  }
@@ -611,7 +611,7 @@ export class SuiClient {
611
611
  params: [
612
612
  typeof input.transactionBlock === 'string'
613
613
  ? input.transactionBlock
614
- : toB64(input.transactionBlock),
614
+ : toBase64(input.transactionBlock),
615
615
  ],
616
616
  });
617
617
  }
@@ -743,8 +743,8 @@ export class SuiClient {
743
743
  // TODO: Migrate this to `sui_getChainIdentifier` once it is widely available.
744
744
  async getChainIdentifier(): Promise<string> {
745
745
  const checkpoint = await this.getCheckpoint({ id: '0' });
746
- const bytes = fromB58(checkpoint.digest);
747
- return toHEX(bytes.slice(0, 4));
746
+ const bytes = fromBase58(checkpoint.digest);
747
+ return toHex(bytes.slice(0, 4));
748
748
  }
749
749
 
750
750
  async resolveNameServiceAddress(input: ResolveNameServiceAddressParams): Promise<string | null> {
@@ -290,8 +290,7 @@ export type SuiEventFilter =
290
290
  Or: [SuiEventFilter, SuiEventFilter];
291
291
  };
292
292
  /**
293
- * Unique ID of a Sui Event, the ID is a combination of tx seq number and event seq number, the ID is
294
- * local to this particular fullnode and will be different from other fullnode.
293
+ * Unique ID of a Sui Event, the ID is a combination of transaction digest and event seq number.
295
294
  */
296
295
  export interface EventId {
297
296
  eventSeq: string;
@@ -1,7 +1,7 @@
1
1
  // Copyright (c) Mysten Labs, Inc.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
- import { bcs, toB64 } from '@mysten/bcs';
4
+ import { bcs, toBase64 } from '@mysten/bcs';
5
5
  import { blake2b } from '@noble/hashes/blake2b';
6
6
  import { bech32 } from 'bech32';
7
7
 
@@ -47,7 +47,7 @@ export abstract class Signer {
47
47
 
48
48
  return {
49
49
  signature,
50
- bytes: toB64(bytes),
50
+ bytes: toBase64(bytes),
51
51
  };
52
52
  }
53
53
  /**
@@ -66,7 +66,7 @@ export abstract class Signer {
66
66
  );
67
67
 
68
68
  return {
69
- bytes: toB64(bytes),
69
+ bytes: toBase64(bytes),
70
70
  signature,
71
71
  };
72
72
  }
@@ -1,6 +1,6 @@
1
1
  // Copyright (c) Mysten Labs, Inc.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
- import { toHEX } from '@mysten/bcs';
3
+ import { toHex } from '@mysten/bcs';
4
4
  import { mnemonicToSeedSync as bip39MnemonicToSeedSync } from '@scure/bip39';
5
5
 
6
6
  /**
@@ -45,5 +45,5 @@ export function mnemonicToSeed(mnemonics: string): Uint8Array {
45
45
  * @param mnemonics 12 words string split by spaces.
46
46
  */
47
47
  export function mnemonicToSeedHex(mnemonics: string): string {
48
- return toHEX(mnemonicToSeed(mnemonics));
48
+ return toHex(mnemonicToSeed(mnemonics));
49
49
  }
@@ -1,7 +1,7 @@
1
1
  // Copyright (c) Mysten Labs, Inc.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
- import { toB64 } from '@mysten/bcs';
4
+ import { toBase64 } from '@mysten/bcs';
5
5
  import { blake2b } from '@noble/hashes/blake2b';
6
6
  import { bytesToHex } from '@noble/hashes/utils';
7
7
 
@@ -45,7 +45,7 @@ export abstract class PublicKey {
45
45
  * Return the base-64 representation of the public key
46
46
  */
47
47
  toBase64() {
48
- return toB64(this.toRawBytes());
48
+ return toBase64(this.toRawBytes());
49
49
  }
50
50
 
51
51
  toString(): never {
@@ -61,7 +61,7 @@ export abstract class PublicKey {
61
61
  */
62
62
  toSuiPublicKey(): string {
63
63
  const bytes = this.toSuiBytes();
64
- return toB64(bytes);
64
+ return toBase64(bytes);
65
65
  }
66
66
 
67
67
  verifyWithIntent(
@@ -1,7 +1,7 @@
1
1
  // Copyright (c) Mysten Labs, Inc.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
- import { fromB64, toB64 } from '@mysten/bcs';
4
+ import { fromBase64, toBase64 } from '@mysten/bcs';
5
5
 
6
6
  import { bcs } from '../bcs/index.js';
7
7
  import type { MultiSigStruct } from '../multisig/publickey.js';
@@ -42,14 +42,14 @@ export function toSerializedSignature({
42
42
  serializedSignature.set([SIGNATURE_SCHEME_TO_FLAG[signatureScheme]]);
43
43
  serializedSignature.set(signature, 1);
44
44
  serializedSignature.set(pubKeyBytes, 1 + signature.length);
45
- return toB64(serializedSignature);
45
+ return toBase64(serializedSignature);
46
46
  }
47
47
 
48
48
  /**
49
49
  * Decodes a serialized signature into its constituent components: the signature scheme, the actual signature, and the public key
50
50
  */
51
51
  export function parseSerializedSignature(serializedSignature: string) {
52
- const bytes = fromB64(serializedSignature);
52
+ const bytes = fromBase64(serializedSignature);
53
53
 
54
54
  const signatureScheme =
55
55
  SIGNATURE_FLAG_TO_SCHEME[bytes[0] as keyof typeof SIGNATURE_FLAG_TO_SCHEME];
@@ -876,9 +876,10 @@ type DynamicField {
876
876
  """
877
877
  name: MoveValue
878
878
  """
879
- The actual data stored in the dynamic field.
880
- The returned dynamic field is an object if its return type is MoveObject,
881
- in which case it is also accessible off-chain via its address.
879
+ The returned dynamic field is an object if its return type is `MoveObject`,
880
+ in which case it is also accessible off-chain via its address. Its contents
881
+ will be from the latest version that is at most equal to its parent object's
882
+ version
882
883
  """
883
884
  value: DynamicFieldValue
884
885
  }
@@ -3008,6 +3009,10 @@ type ServiceConfig {
3008
3009
  """
3009
3010
  isEnabled(feature: Feature!): Boolean!
3010
3011
  """
3012
+ List the available versions for this GraphQL service.
3013
+ """
3014
+ availableVersions: [String!]!
3015
+ """
3011
3016
  List of all features that are enabled on this GraphQL service.
3012
3017
  """
3013
3018
  enabledFeatures: [Feature!]!
@@ -3046,7 +3051,14 @@ type ServiceConfig {
3046
3051
  """
3047
3052
  maxPageSize: Int!
3048
3053
  """
3049
- Maximum time in milliseconds that will be spent to serve one request.
3054
+ Maximum time in milliseconds spent waiting for a response from fullnode after issuing a
3055
+ a transaction to execute. Note that the transaction may still succeed even in the case of a
3056
+ timeout. Transactions are idempotent, so a transaction that times out should be resubmitted
3057
+ until the network returns a definite response (success or failure, not timeout).
3058
+ """
3059
+ mutationTimeoutMs: Int!
3060
+ """
3061
+ Maximum time in milliseconds that will be spent to serve one query request.
3050
3062
  """
3051
3063
  requestTimeoutMs: Int!
3052
3064
  """
@@ -3700,6 +3712,8 @@ type TransactionBlockEffects {
3700
3712
  lamportVersion: Int!
3701
3713
  """
3702
3714
  The reason for a transaction failure, if it did fail.
3715
+ If the error is a Move abort, the error message will be resolved to a human-readable form if
3716
+ possible, otherwise it will fall back to displaying the abort code and location.
3703
3717
  """
3704
3718
  errors: String
3705
3719
  """
@@ -146,7 +146,7 @@ export type introspection = {
146
146
  'Receiving': { kind: 'OBJECT'; name: 'Receiving'; fields: { 'address': { name: 'address'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'SCALAR'; name: 'SuiAddress'; ofType: null; }; } }; 'digest': { name: 'digest'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'SCALAR'; name: 'String'; ofType: null; }; } }; 'object': { name: 'object'; type: { kind: 'OBJECT'; name: 'Object'; ofType: null; } }; 'version': { name: 'version'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'SCALAR'; name: 'Int'; ofType: null; }; } }; }; };
147
147
  'Result': { kind: 'OBJECT'; name: 'Result'; fields: { 'cmd': { name: 'cmd'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'SCALAR'; name: 'Int'; ofType: null; }; } }; 'ix': { name: 'ix'; type: { kind: 'SCALAR'; name: 'Int'; ofType: null; } }; }; };
148
148
  'SafeMode': { kind: 'OBJECT'; name: 'SafeMode'; fields: { 'enabled': { name: 'enabled'; type: { kind: 'SCALAR'; name: 'Boolean'; ofType: null; } }; 'gasSummary': { name: 'gasSummary'; type: { kind: 'OBJECT'; name: 'GasCostSummary'; ofType: null; } }; }; };
149
- 'ServiceConfig': { kind: 'OBJECT'; name: 'ServiceConfig'; fields: { 'defaultPageSize': { name: 'defaultPageSize'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'SCALAR'; name: 'Int'; ofType: null; }; } }; 'enabledFeatures': { name: 'enabledFeatures'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'LIST'; name: never; ofType: { kind: 'NON_NULL'; name: never; ofType: { kind: 'ENUM'; name: 'Feature'; ofType: null; }; }; }; } }; 'isEnabled': { name: 'isEnabled'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'SCALAR'; name: 'Boolean'; ofType: null; }; } }; 'maxDbQueryCost': { name: 'maxDbQueryCost'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'SCALAR'; name: 'BigInt'; ofType: null; }; } }; 'maxMoveValueDepth': { name: 'maxMoveValueDepth'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'SCALAR'; name: 'Int'; ofType: null; }; } }; 'maxOutputNodes': { name: 'maxOutputNodes'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'SCALAR'; name: 'Int'; ofType: null; }; } }; 'maxPageSize': { name: 'maxPageSize'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'SCALAR'; name: 'Int'; ofType: null; }; } }; 'maxQueryDepth': { name: 'maxQueryDepth'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'SCALAR'; name: 'Int'; ofType: null; }; } }; 'maxQueryNodes': { name: 'maxQueryNodes'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'SCALAR'; name: 'Int'; ofType: null; }; } }; 'maxQueryPayloadSize': { name: 'maxQueryPayloadSize'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'SCALAR'; name: 'Int'; ofType: null; }; } }; 'maxTypeArgumentDepth': { name: 'maxTypeArgumentDepth'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'SCALAR'; name: 'Int'; ofType: null; }; } }; 'maxTypeArgumentWidth': { name: 'maxTypeArgumentWidth'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'SCALAR'; name: 'Int'; ofType: null; }; } }; 'maxTypeNodes': { name: 'maxTypeNodes'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'SCALAR'; name: 'Int'; ofType: null; }; } }; 'requestTimeoutMs': { name: 'requestTimeoutMs'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'SCALAR'; name: 'Int'; ofType: null; }; } }; }; };
149
+ 'ServiceConfig': { kind: 'OBJECT'; name: 'ServiceConfig'; fields: { 'availableVersions': { name: 'availableVersions'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'LIST'; name: never; ofType: { kind: 'NON_NULL'; name: never; ofType: { kind: 'SCALAR'; name: 'String'; ofType: null; }; }; }; } }; 'defaultPageSize': { name: 'defaultPageSize'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'SCALAR'; name: 'Int'; ofType: null; }; } }; 'enabledFeatures': { name: 'enabledFeatures'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'LIST'; name: never; ofType: { kind: 'NON_NULL'; name: never; ofType: { kind: 'ENUM'; name: 'Feature'; ofType: null; }; }; }; } }; 'isEnabled': { name: 'isEnabled'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'SCALAR'; name: 'Boolean'; ofType: null; }; } }; 'maxDbQueryCost': { name: 'maxDbQueryCost'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'SCALAR'; name: 'BigInt'; ofType: null; }; } }; 'maxMoveValueDepth': { name: 'maxMoveValueDepth'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'SCALAR'; name: 'Int'; ofType: null; }; } }; 'maxOutputNodes': { name: 'maxOutputNodes'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'SCALAR'; name: 'Int'; ofType: null; }; } }; 'maxPageSize': { name: 'maxPageSize'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'SCALAR'; name: 'Int'; ofType: null; }; } }; 'maxQueryDepth': { name: 'maxQueryDepth'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'SCALAR'; name: 'Int'; ofType: null; }; } }; 'maxQueryNodes': { name: 'maxQueryNodes'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'SCALAR'; name: 'Int'; ofType: null; }; } }; 'maxQueryPayloadSize': { name: 'maxQueryPayloadSize'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'SCALAR'; name: 'Int'; ofType: null; }; } }; 'maxTypeArgumentDepth': { name: 'maxTypeArgumentDepth'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'SCALAR'; name: 'Int'; ofType: null; }; } }; 'maxTypeArgumentWidth': { name: 'maxTypeArgumentWidth'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'SCALAR'; name: 'Int'; ofType: null; }; } }; 'maxTypeNodes': { name: 'maxTypeNodes'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'SCALAR'; name: 'Int'; ofType: null; }; } }; 'mutationTimeoutMs': { name: 'mutationTimeoutMs'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'SCALAR'; name: 'Int'; ofType: null; }; } }; 'requestTimeoutMs': { name: 'requestTimeoutMs'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'SCALAR'; name: 'Int'; ofType: null; }; } }; }; };
150
150
  'Shared': { kind: 'OBJECT'; name: 'Shared'; fields: { 'initialSharedVersion': { name: 'initialSharedVersion'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'SCALAR'; name: 'Int'; ofType: null; }; } }; }; };
151
151
  'SharedInput': { kind: 'OBJECT'; name: 'SharedInput'; fields: { 'address': { name: 'address'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'SCALAR'; name: 'SuiAddress'; ofType: null; }; } }; 'initialSharedVersion': { name: 'initialSharedVersion'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'SCALAR'; name: 'Int'; ofType: null; }; } }; 'mutable': { name: 'mutable'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'SCALAR'; name: 'Boolean'; ofType: null; }; } }; }; };
152
152
  'SharedObjectDelete': { kind: 'OBJECT'; name: 'SharedObjectDelete'; fields: { 'address': { name: 'address'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'SCALAR'; name: 'SuiAddress'; ofType: null; }; } }; 'mutable': { name: 'mutable'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'SCALAR'; name: 'Boolean'; ofType: null; }; } }; 'version': { name: 'version'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'SCALAR'; name: 'Int'; ofType: null; }; } }; }; };
@@ -881,9 +881,10 @@ type DynamicField {
881
881
  """
882
882
  name: MoveValue
883
883
  """
884
- The actual data stored in the dynamic field.
885
- The returned dynamic field is an object if its return type is MoveObject,
886
- in which case it is also accessible off-chain via its address.
884
+ The returned dynamic field is an object if its return type is `MoveObject`,
885
+ in which case it is also accessible off-chain via its address. Its contents
886
+ will be from the latest version that is at most equal to its parent object's
887
+ version
887
888
  """
888
889
  value: DynamicFieldValue
889
890
  }
@@ -3013,6 +3014,10 @@ type ServiceConfig {
3013
3014
  """
3014
3015
  isEnabled(feature: Feature!): Boolean!
3015
3016
  """
3017
+ List the available versions for this GraphQL service.
3018
+ """
3019
+ availableVersions: [String!]!
3020
+ """
3016
3021
  List of all features that are enabled on this GraphQL service.
3017
3022
  """
3018
3023
  enabledFeatures: [Feature!]!
@@ -3051,7 +3056,14 @@ type ServiceConfig {
3051
3056
  """
3052
3057
  maxPageSize: Int!
3053
3058
  """
3054
- Maximum time in milliseconds that will be spent to serve one request.
3059
+ Maximum time in milliseconds spent waiting for a response from fullnode after issuing a
3060
+ a transaction to execute. Note that the transaction may still succeed even in the case of a
3061
+ timeout. Transactions are idempotent, so a transaction that times out should be resubmitted
3062
+ until the network returns a definite response (success or failure, not timeout).
3063
+ """
3064
+ mutationTimeoutMs: Int!
3065
+ """
3066
+ Maximum time in milliseconds that will be spent to serve one query request.
3055
3067
  """
3056
3068
  requestTimeoutMs: Int!
3057
3069
  """
@@ -3105,6 +3117,20 @@ type SharedInput {
3105
3117
  mutable: Boolean!
3106
3118
  }
3107
3119
 
3120
+ """
3121
+ The transaction accpeted a shared object as input, but its execution was cancelled.
3122
+ """
3123
+ type SharedObjectCancelled {
3124
+ """
3125
+ ID of the shared object.
3126
+ """
3127
+ address: SuiAddress!
3128
+ """
3129
+ The assigned shared object version. It is a special version indicating transaction cancellation reason.
3130
+ """
3131
+ version: Int!
3132
+ }
3133
+
3108
3134
  """
3109
3135
  The transaction accepted a shared object as input, but it was deleted before the transaction
3110
3136
  executed.
@@ -3705,6 +3731,8 @@ type TransactionBlockEffects {
3705
3731
  lamportVersion: Int!
3706
3732
  """
3707
3733
  The reason for a transaction failure, if it did fail.
3734
+ If the error is a Move abort, the error message will be resolved to a human-readable form if
3735
+ possible, otherwise it will fall back to displaying the abort code and location.
3708
3736
  """
3709
3737
  errors: String
3710
3738
  """
@@ -3871,7 +3899,7 @@ This information is considered part of the effects, because although the transac
3871
3899
  the shared object as input, consensus must schedule it and pick the version that is actually
3872
3900
  used.
3873
3901
  """
3874
- union UnchangedSharedObject = SharedObjectRead | SharedObjectDelete
3902
+ union UnchangedSharedObject = SharedObjectRead | SharedObjectDelete | SharedObjectCancelled
3875
3903
 
3876
3904
  type UnchangedSharedObjectConnection {
3877
3905
  """
@@ -147,9 +147,10 @@ export type introspection = {
147
147
  'Receiving': { kind: 'OBJECT'; name: 'Receiving'; fields: { 'address': { name: 'address'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'SCALAR'; name: 'SuiAddress'; ofType: null; }; } }; 'digest': { name: 'digest'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'SCALAR'; name: 'String'; ofType: null; }; } }; 'object': { name: 'object'; type: { kind: 'OBJECT'; name: 'Object'; ofType: null; } }; 'version': { name: 'version'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'SCALAR'; name: 'Int'; ofType: null; }; } }; }; };
148
148
  'Result': { kind: 'OBJECT'; name: 'Result'; fields: { 'cmd': { name: 'cmd'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'SCALAR'; name: 'Int'; ofType: null; }; } }; 'ix': { name: 'ix'; type: { kind: 'SCALAR'; name: 'Int'; ofType: null; } }; }; };
149
149
  'SafeMode': { kind: 'OBJECT'; name: 'SafeMode'; fields: { 'enabled': { name: 'enabled'; type: { kind: 'SCALAR'; name: 'Boolean'; ofType: null; } }; 'gasSummary': { name: 'gasSummary'; type: { kind: 'OBJECT'; name: 'GasCostSummary'; ofType: null; } }; }; };
150
- 'ServiceConfig': { kind: 'OBJECT'; name: 'ServiceConfig'; fields: { 'defaultPageSize': { name: 'defaultPageSize'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'SCALAR'; name: 'Int'; ofType: null; }; } }; 'enabledFeatures': { name: 'enabledFeatures'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'LIST'; name: never; ofType: { kind: 'NON_NULL'; name: never; ofType: { kind: 'ENUM'; name: 'Feature'; ofType: null; }; }; }; } }; 'isEnabled': { name: 'isEnabled'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'SCALAR'; name: 'Boolean'; ofType: null; }; } }; 'maxDbQueryCost': { name: 'maxDbQueryCost'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'SCALAR'; name: 'BigInt'; ofType: null; }; } }; 'maxMoveValueDepth': { name: 'maxMoveValueDepth'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'SCALAR'; name: 'Int'; ofType: null; }; } }; 'maxOutputNodes': { name: 'maxOutputNodes'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'SCALAR'; name: 'Int'; ofType: null; }; } }; 'maxPageSize': { name: 'maxPageSize'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'SCALAR'; name: 'Int'; ofType: null; }; } }; 'maxQueryDepth': { name: 'maxQueryDepth'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'SCALAR'; name: 'Int'; ofType: null; }; } }; 'maxQueryNodes': { name: 'maxQueryNodes'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'SCALAR'; name: 'Int'; ofType: null; }; } }; 'maxQueryPayloadSize': { name: 'maxQueryPayloadSize'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'SCALAR'; name: 'Int'; ofType: null; }; } }; 'maxTypeArgumentDepth': { name: 'maxTypeArgumentDepth'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'SCALAR'; name: 'Int'; ofType: null; }; } }; 'maxTypeArgumentWidth': { name: 'maxTypeArgumentWidth'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'SCALAR'; name: 'Int'; ofType: null; }; } }; 'maxTypeNodes': { name: 'maxTypeNodes'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'SCALAR'; name: 'Int'; ofType: null; }; } }; 'requestTimeoutMs': { name: 'requestTimeoutMs'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'SCALAR'; name: 'Int'; ofType: null; }; } }; }; };
150
+ 'ServiceConfig': { kind: 'OBJECT'; name: 'ServiceConfig'; fields: { 'availableVersions': { name: 'availableVersions'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'LIST'; name: never; ofType: { kind: 'NON_NULL'; name: never; ofType: { kind: 'SCALAR'; name: 'String'; ofType: null; }; }; }; } }; 'defaultPageSize': { name: 'defaultPageSize'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'SCALAR'; name: 'Int'; ofType: null; }; } }; 'enabledFeatures': { name: 'enabledFeatures'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'LIST'; name: never; ofType: { kind: 'NON_NULL'; name: never; ofType: { kind: 'ENUM'; name: 'Feature'; ofType: null; }; }; }; } }; 'isEnabled': { name: 'isEnabled'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'SCALAR'; name: 'Boolean'; ofType: null; }; } }; 'maxDbQueryCost': { name: 'maxDbQueryCost'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'SCALAR'; name: 'BigInt'; ofType: null; }; } }; 'maxMoveValueDepth': { name: 'maxMoveValueDepth'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'SCALAR'; name: 'Int'; ofType: null; }; } }; 'maxOutputNodes': { name: 'maxOutputNodes'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'SCALAR'; name: 'Int'; ofType: null; }; } }; 'maxPageSize': { name: 'maxPageSize'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'SCALAR'; name: 'Int'; ofType: null; }; } }; 'maxQueryDepth': { name: 'maxQueryDepth'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'SCALAR'; name: 'Int'; ofType: null; }; } }; 'maxQueryNodes': { name: 'maxQueryNodes'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'SCALAR'; name: 'Int'; ofType: null; }; } }; 'maxQueryPayloadSize': { name: 'maxQueryPayloadSize'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'SCALAR'; name: 'Int'; ofType: null; }; } }; 'maxTypeArgumentDepth': { name: 'maxTypeArgumentDepth'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'SCALAR'; name: 'Int'; ofType: null; }; } }; 'maxTypeArgumentWidth': { name: 'maxTypeArgumentWidth'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'SCALAR'; name: 'Int'; ofType: null; }; } }; 'maxTypeNodes': { name: 'maxTypeNodes'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'SCALAR'; name: 'Int'; ofType: null; }; } }; 'mutationTimeoutMs': { name: 'mutationTimeoutMs'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'SCALAR'; name: 'Int'; ofType: null; }; } }; 'requestTimeoutMs': { name: 'requestTimeoutMs'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'SCALAR'; name: 'Int'; ofType: null; }; } }; }; };
151
151
  'Shared': { kind: 'OBJECT'; name: 'Shared'; fields: { 'initialSharedVersion': { name: 'initialSharedVersion'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'SCALAR'; name: 'Int'; ofType: null; }; } }; }; };
152
152
  'SharedInput': { kind: 'OBJECT'; name: 'SharedInput'; fields: { 'address': { name: 'address'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'SCALAR'; name: 'SuiAddress'; ofType: null; }; } }; 'initialSharedVersion': { name: 'initialSharedVersion'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'SCALAR'; name: 'Int'; ofType: null; }; } }; 'mutable': { name: 'mutable'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'SCALAR'; name: 'Boolean'; ofType: null; }; } }; }; };
153
+ 'SharedObjectCancelled': { kind: 'OBJECT'; name: 'SharedObjectCancelled'; fields: { 'address': { name: 'address'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'SCALAR'; name: 'SuiAddress'; ofType: null; }; } }; 'version': { name: 'version'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'SCALAR'; name: 'Int'; ofType: null; }; } }; }; };
153
154
  'SharedObjectDelete': { kind: 'OBJECT'; name: 'SharedObjectDelete'; fields: { 'address': { name: 'address'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'SCALAR'; name: 'SuiAddress'; ofType: null; }; } }; 'mutable': { name: 'mutable'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'SCALAR'; name: 'Boolean'; ofType: null; }; } }; 'version': { name: 'version'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'SCALAR'; name: 'Int'; ofType: null; }; } }; }; };
154
155
  'SharedObjectRead': { kind: 'OBJECT'; name: 'SharedObjectRead'; fields: { 'address': { name: 'address'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'SCALAR'; name: 'SuiAddress'; ofType: null; }; } }; 'digest': { name: 'digest'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'SCALAR'; name: 'String'; ofType: null; }; } }; 'object': { name: 'object'; type: { kind: 'OBJECT'; name: 'Object'; ofType: null; } }; 'version': { name: 'version'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'SCALAR'; name: 'Int'; ofType: null; }; } }; }; };
155
156
  'SplitCoinsTransaction': { kind: 'OBJECT'; name: 'SplitCoinsTransaction'; fields: { 'amounts': { name: 'amounts'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'LIST'; name: never; ofType: { kind: 'NON_NULL'; name: never; ofType: { kind: 'UNION'; name: 'TransactionArgument'; ofType: null; }; }; }; } }; 'coin': { name: 'coin'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'UNION'; name: 'TransactionArgument'; ofType: null; }; } }; }; };
@@ -179,7 +180,7 @@ export type introspection = {
179
180
  'TransactionMetadata': { kind: 'INPUT_OBJECT'; name: 'TransactionMetadata'; isOneOf: false; inputFields: [{ name: 'sender'; type: { kind: 'SCALAR'; name: 'SuiAddress'; ofType: null; }; defaultValue: null }, { name: 'gasPrice'; type: { kind: 'SCALAR'; name: 'Int'; ofType: null; }; defaultValue: null }, { name: 'gasObjects'; type: { kind: 'LIST'; name: never; ofType: { kind: 'NON_NULL'; name: never; ofType: { kind: 'INPUT_OBJECT'; name: 'ObjectRef'; ofType: null; }; }; }; defaultValue: null }, { name: 'gasBudget'; type: { kind: 'SCALAR'; name: 'Int'; ofType: null; }; defaultValue: null }, { name: 'gasSponsor'; type: { kind: 'SCALAR'; name: 'SuiAddress'; ofType: null; }; defaultValue: null }]; };
180
181
  'TransferObjectsTransaction': { kind: 'OBJECT'; name: 'TransferObjectsTransaction'; fields: { 'address': { name: 'address'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'UNION'; name: 'TransactionArgument'; ofType: null; }; } }; 'inputs': { name: 'inputs'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'LIST'; name: never; ofType: { kind: 'NON_NULL'; name: never; ofType: { kind: 'UNION'; name: 'TransactionArgument'; ofType: null; }; }; }; } }; }; };
181
182
  'TypeOrigin': { kind: 'OBJECT'; name: 'TypeOrigin'; fields: { 'definingId': { name: 'definingId'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'SCALAR'; name: 'SuiAddress'; ofType: null; }; } }; 'module': { name: 'module'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'SCALAR'; name: 'String'; ofType: null; }; } }; 'struct': { name: 'struct'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'SCALAR'; name: 'String'; ofType: null; }; } }; }; };
182
- 'UnchangedSharedObject': { kind: 'UNION'; name: 'UnchangedSharedObject'; fields: {}; possibleTypes: 'SharedObjectDelete' | 'SharedObjectRead'; };
183
+ 'UnchangedSharedObject': { kind: 'UNION'; name: 'UnchangedSharedObject'; fields: {}; possibleTypes: 'SharedObjectCancelled' | 'SharedObjectDelete' | 'SharedObjectRead'; };
183
184
  'UnchangedSharedObjectConnection': { kind: 'OBJECT'; name: 'UnchangedSharedObjectConnection'; fields: { 'edges': { name: 'edges'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'LIST'; name: never; ofType: { kind: 'NON_NULL'; name: never; ofType: { kind: 'OBJECT'; name: 'UnchangedSharedObjectEdge'; ofType: null; }; }; }; } }; 'nodes': { name: 'nodes'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'LIST'; name: never; ofType: { kind: 'NON_NULL'; name: never; ofType: { kind: 'UNION'; name: 'UnchangedSharedObject'; ofType: null; }; }; }; } }; 'pageInfo': { name: 'pageInfo'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'OBJECT'; name: 'PageInfo'; ofType: null; }; } }; }; };
184
185
  'UnchangedSharedObjectEdge': { kind: 'OBJECT'; name: 'UnchangedSharedObjectEdge'; fields: { 'cursor': { name: 'cursor'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'SCALAR'; name: 'String'; ofType: null; }; } }; 'node': { name: 'node'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'UNION'; name: 'UnchangedSharedObject'; ofType: null; }; } }; }; };
185
186
  'UpgradeTransaction': { kind: 'OBJECT'; name: 'UpgradeTransaction'; fields: { 'currentPackage': { name: 'currentPackage'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'SCALAR'; name: 'SuiAddress'; ofType: null; }; } }; 'dependencies': { name: 'dependencies'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'LIST'; name: never; ofType: { kind: 'NON_NULL'; name: never; ofType: { kind: 'SCALAR'; name: 'SuiAddress'; ofType: null; }; }; }; } }; 'modules': { name: 'modules'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'LIST'; name: never; ofType: { kind: 'NON_NULL'; name: never; ofType: { kind: 'SCALAR'; name: 'Base64'; ofType: null; }; }; }; } }; 'upgradeTicket': { name: 'upgradeTicket'; type: { kind: 'NON_NULL'; name: never; ofType: { kind: 'UNION'; name: 'TransactionArgument'; ofType: null; }; } }; }; };
@@ -4,7 +4,7 @@
4
4
  // This is adapted from https://github.com/alepop/ed25519-hd-key replacing create-hmac
5
5
  // with @noble/hashes to be browser compatible.
6
6
 
7
- import { fromHEX } from '@mysten/bcs';
7
+ import { fromHex } from '@mysten/bcs';
8
8
  import { hmac } from '@noble/hashes/hmac';
9
9
  import { sha512 } from '@noble/hashes/sha512';
10
10
  import nacl from 'tweetnacl';
@@ -26,7 +26,7 @@ export const replaceDerive = (val: string): string => val.replace("'", '');
26
26
 
27
27
  export const getMasterKeyFromSeed = (seed: Hex): Keys => {
28
28
  const h = hmac.create(sha512, ED25519_CURVE);
29
- const I = h.update(fromHEX(seed)).digest();
29
+ const I = h.update(fromHex(seed)).digest();
30
30
  const IL = I.slice(0, 32);
31
31
  const IR = I.slice(32);
32
32
  return {
@@ -3,7 +3,12 @@
3
3
 
4
4
  import nacl from 'tweetnacl';
5
5
 
6
- import { encodeSuiPrivateKey, Keypair, PRIVATE_KEY_SIZE } from '../../cryptography/keypair.js';
6
+ import {
7
+ decodeSuiPrivateKey,
8
+ encodeSuiPrivateKey,
9
+ Keypair,
10
+ PRIVATE_KEY_SIZE,
11
+ } from '../../cryptography/keypair.js';
7
12
  import { isValidHardenedPath, mnemonicToSeedHex } from '../../cryptography/mnemonics.js';
8
13
  import type { SignatureScheme } from '../../cryptography/signature-scheme.js';
9
14
  import { derivePath } from './ed25519-hd-key.js';
@@ -63,13 +68,23 @@ export class Ed25519Keypair extends Keypair {
63
68
  *
64
69
  * @throws error if the provided secret key is invalid and validation is not skipped.
65
70
  *
66
- * @param secretKey secret key byte array
71
+ * @param secretKey secret key as a byte array or Bech32 secret key string
67
72
  * @param options: skip secret key validation
68
73
  */
69
74
  static fromSecretKey(
70
- secretKey: Uint8Array,
75
+ secretKey: Uint8Array | string,
71
76
  options?: { skipValidation?: boolean },
72
77
  ): Ed25519Keypair {
78
+ if (typeof secretKey === 'string') {
79
+ const decoded = decodeSuiPrivateKey(secretKey);
80
+
81
+ if (decoded.schema !== 'ED25519') {
82
+ throw new Error(`Expected a ED25519 keypair, got ${decoded.schema}`);
83
+ }
84
+
85
+ return this.fromSecretKey(decoded.secretKey, options);
86
+ }
87
+
73
88
  const secretKeyLength = secretKey.length;
74
89
  if (secretKeyLength !== PRIVATE_KEY_SIZE) {
75
90
  throw new Error(
@@ -1,7 +1,7 @@
1
1
  // Copyright (c) Mysten Labs, Inc.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
- import { fromB64 } from '@mysten/bcs';
4
+ import { fromBase64 } from '@mysten/bcs';
5
5
  import nacl from 'tweetnacl';
6
6
 
7
7
  import type { PublicKeyInitData } from '../../cryptography/publickey.js';
@@ -26,7 +26,7 @@ export class Ed25519PublicKey extends PublicKey {
26
26
  super();
27
27
 
28
28
  if (typeof value === 'string') {
29
- this.data = fromB64(value);
29
+ this.data = fromBase64(value);
30
30
  } else if (value instanceof Uint8Array) {
31
31
  this.data = value;
32
32
  } else {
@@ -7,7 +7,7 @@ import { sha256 } from '@noble/hashes/sha256';
7
7
  import { bytesToHex } from '@noble/hashes/utils';
8
8
  import { HDKey } from '@scure/bip32';
9
9
 
10
- import { encodeSuiPrivateKey, Keypair } from '../../cryptography/keypair.js';
10
+ import { decodeSuiPrivateKey, encodeSuiPrivateKey, Keypair } from '../../cryptography/keypair.js';
11
11
  import { isValidBIP32Path, mnemonicToSeed } from '../../cryptography/mnemonics.js';
12
12
  import type { PublicKey } from '../../cryptography/publickey.js';
13
13
  import type { SignatureScheme } from '../../cryptography/signature-scheme.js';
@@ -70,14 +70,24 @@ export class Secp256k1Keypair extends Keypair {
70
70
  *
71
71
  * @throws error if the provided secret key is invalid and validation is not skipped.
72
72
  *
73
- * @param secretKey secret key byte array
73
+ * @param secretKey secret key byte array or Bech32 secret key string
74
74
  * @param options: skip secret key validation
75
75
  */
76
76
 
77
77
  static fromSecretKey(
78
- secretKey: Uint8Array,
78
+ secretKey: Uint8Array | string,
79
79
  options?: { skipValidation?: boolean },
80
80
  ): Secp256k1Keypair {
81
+ if (typeof secretKey === 'string') {
82
+ const decoded = decodeSuiPrivateKey(secretKey);
83
+
84
+ if (decoded.schema !== 'Secp256k1') {
85
+ throw new Error(`Expected a Secp256k1 keypair, got ${decoded.schema}`);
86
+ }
87
+
88
+ return this.fromSecretKey(decoded.secretKey, options);
89
+ }
90
+
81
91
  const publicKey: Uint8Array = secp256k1.getPublicKey(secretKey, true);
82
92
  if (!options || !options.skipValidation) {
83
93
  const encoder = new TextEncoder();
@@ -1,7 +1,7 @@
1
1
  // Copyright (c) Mysten Labs, Inc.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
- import { fromB64 } from '@mysten/bcs';
4
+ import { fromBase64 } from '@mysten/bcs';
5
5
  import { secp256k1 } from '@noble/curves/secp256k1';
6
6
  import { sha256 } from '@noble/hashes/sha256';
7
7
 
@@ -27,7 +27,7 @@ export class Secp256k1PublicKey extends PublicKey {
27
27
  super();
28
28
 
29
29
  if (typeof value === 'string') {
30
- this.data = fromB64(value);
30
+ this.data = fromBase64(value);
31
31
  } else if (value instanceof Uint8Array) {
32
32
  this.data = value;
33
33
  } else {
@@ -7,7 +7,7 @@ import { sha256 } from '@noble/hashes/sha256';
7
7
  import { bytesToHex } from '@noble/hashes/utils';
8
8
  import { HDKey } from '@scure/bip32';
9
9
 
10
- import { encodeSuiPrivateKey, Keypair } from '../../cryptography/keypair.js';
10
+ import { decodeSuiPrivateKey, encodeSuiPrivateKey, Keypair } from '../../cryptography/keypair.js';
11
11
  import { isValidBIP32Path, mnemonicToSeed } from '../../cryptography/mnemonics.js';
12
12
  import type { PublicKey } from '../../cryptography/publickey.js';
13
13
  import type { SignatureScheme } from '../../cryptography/signature-scheme.js';
@@ -70,14 +70,24 @@ export class Secp256r1Keypair extends Keypair {
70
70
  *
71
71
  * @throws error if the provided secret key is invalid and validation is not skipped.
72
72
  *
73
- * @param secretKey secret key byte array
73
+ * @param secretKey secret key byte array or Bech32 secret key string
74
74
  * @param options: skip secret key validation
75
75
  */
76
76
 
77
77
  static fromSecretKey(
78
- secretKey: Uint8Array,
78
+ secretKey: Uint8Array | string,
79
79
  options?: { skipValidation?: boolean },
80
80
  ): Secp256r1Keypair {
81
+ if (typeof secretKey === 'string') {
82
+ const decoded = decodeSuiPrivateKey(secretKey);
83
+
84
+ if (decoded.schema !== 'Secp256r1') {
85
+ throw new Error(`Expected a Secp256r1 keypair, got ${decoded.schema}`);
86
+ }
87
+
88
+ return this.fromSecretKey(decoded.secretKey, options);
89
+ }
90
+
81
91
  const publicKey: Uint8Array = secp256r1.getPublicKey(secretKey, true);
82
92
  if (!options || !options.skipValidation) {
83
93
  const encoder = new TextEncoder();
@@ -1,7 +1,7 @@
1
1
  // Copyright (c) Mysten Labs, Inc.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
- import { fromB64 } from '@mysten/bcs';
4
+ import { fromBase64 } from '@mysten/bcs';
5
5
  import { secp256r1 } from '@noble/curves/p256';
6
6
  import { sha256 } from '@noble/hashes/sha256';
7
7
 
@@ -27,7 +27,7 @@ export class Secp256r1PublicKey extends PublicKey {
27
27
  super();
28
28
 
29
29
  if (typeof value === 'string') {
30
- this.data = fromB64(value);
30
+ this.data = fromBase64(value);
31
31
  } else if (value instanceof Uint8Array) {
32
32
  this.data = value;
33
33
  } else {