@haneullabs/haneul 2.4.0 → 2.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/dist/bcs/bcs.mjs +1 -1
  2. package/dist/bcs/bcs.mjs.map +1 -1
  3. package/dist/bcs/index.d.mts +4 -4
  4. package/dist/client/core-resolver.mjs +2 -2
  5. package/dist/client/core-resolver.mjs.map +1 -1
  6. package/dist/client/core.mjs +1 -1
  7. package/dist/client/core.mjs.map +1 -1
  8. package/dist/cryptography/keypair.d.mts +1 -1
  9. package/dist/cryptography/keypair.mjs +3 -3
  10. package/dist/cryptography/keypair.mjs.map +1 -1
  11. package/dist/cryptography/publickey.d.mts +1 -1
  12. package/dist/cryptography/publickey.mjs +2 -2
  13. package/dist/cryptography/publickey.mjs.map +1 -1
  14. package/dist/cryptography/signature.d.mts +6 -6
  15. package/dist/grpc/proto/haneul/rpc/v2/ledger_service.client.d.mts +4 -4
  16. package/dist/grpc/proto/haneul/rpc/v2/move_package_service.client.d.mts +4 -4
  17. package/dist/grpc/proto/haneul/rpc/v2/state_service.client.d.mts +4 -4
  18. package/dist/grpc/proto/haneul/rpc/v2/subscription_service.client.d.mts +4 -4
  19. package/dist/grpc/proto/haneul/rpc/v2/system_state.d.mts +2 -2
  20. package/dist/grpc/proto/haneul/rpc/v2/system_state.mjs +1 -1
  21. package/dist/grpc/proto/haneul/rpc/v2/system_state.mjs.map +1 -1
  22. package/dist/grpc/proto/haneul/rpc/v2/transaction_execution_service.client.d.mts +4 -4
  23. package/dist/jsonRpc/client.d.mts +5 -5
  24. package/dist/jsonRpc/client.d.mts.map +1 -1
  25. package/dist/jsonRpc/client.mjs +56 -56
  26. package/dist/jsonRpc/client.mjs.map +1 -1
  27. package/dist/jsonRpc/core.mjs +6 -6
  28. package/dist/jsonRpc/core.mjs.map +1 -1
  29. package/dist/jsonRpc/index.d.mts +4 -4
  30. package/dist/jsonRpc/index.mjs +2 -2
  31. package/dist/jsonRpc/types/generated.d.mts +14 -14
  32. package/dist/jsonRpc/types/generated.d.mts.map +1 -1
  33. package/dist/jsonRpc/types/index.d.mts +2 -2
  34. package/dist/jsonRpc/types/params.d.mts +8 -8
  35. package/dist/jsonRpc/types/params.d.mts.map +1 -1
  36. package/dist/multisig/publickey.d.mts +1 -1
  37. package/dist/multisig/publickey.mjs +1 -1
  38. package/dist/multisig/publickey.mjs.map +1 -1
  39. package/dist/multisig/signer.mjs +2 -2
  40. package/dist/multisig/signer.mjs.map +1 -1
  41. package/dist/transactions/Commands.mjs +3 -3
  42. package/dist/transactions/Commands.mjs.map +1 -1
  43. package/dist/transactions/executor/caching.mjs +1 -1
  44. package/dist/transactions/executor/caching.mjs.map +1 -1
  45. package/dist/transactions/executor/parallel.mjs +3 -3
  46. package/dist/transactions/executor/parallel.mjs.map +1 -1
  47. package/dist/transactions/executor/serial.mjs +1 -1
  48. package/dist/transactions/executor/serial.mjs.map +1 -1
  49. package/dist/utils/haneul-types.d.mts +2 -2
  50. package/dist/utils/haneul-types.d.mts.map +1 -1
  51. package/dist/utils/haneul-types.mjs +2 -2
  52. package/dist/utils/haneul-types.mjs.map +1 -1
  53. package/dist/utils/index.d.mts +2 -2
  54. package/dist/utils/index.mjs +2 -2
  55. package/dist/verify/verify.mjs +1 -1
  56. package/dist/verify/verify.mjs.map +1 -1
  57. package/dist/zklogin/publickey.d.mts +1 -1
  58. package/dist/zklogin/publickey.d.mts.map +1 -1
  59. package/dist/zklogin/publickey.mjs +9 -9
  60. package/dist/zklogin/publickey.mjs.map +1 -1
  61. package/package.json +199 -199
  62. package/src/bcs/bcs.ts +1 -1
  63. package/src/client/core-resolver.ts +2 -2
  64. package/src/client/core.ts +1 -1
  65. package/src/cryptography/keypair.ts +3 -3
  66. package/src/cryptography/publickey.ts +2 -2
  67. package/src/grpc/proto/haneul/rpc/v2/system_state.ts +3 -3
  68. package/src/jsonRpc/client.ts +57 -57
  69. package/src/jsonRpc/core.ts +7 -7
  70. package/src/jsonRpc/index.ts +1 -1
  71. package/src/jsonRpc/types/generated.ts +13 -13
  72. package/src/jsonRpc/types/params.ts +7 -7
  73. package/src/multisig/publickey.ts +1 -1
  74. package/src/multisig/signer.ts +2 -2
  75. package/src/transactions/Commands.ts +3 -3
  76. package/src/transactions/executor/caching.ts +1 -1
  77. package/src/transactions/executor/parallel.ts +3 -3
  78. package/src/transactions/executor/serial.ts +1 -1
  79. package/src/utils/haneul-types.ts +1 -1
  80. package/src/utils/index.ts +1 -1
  81. package/src/verify/verify.ts +1 -1
  82. package/src/zklogin/publickey.ts +9 -9
@@ -1 +1 @@
1
- {"version":3,"file":"verify.mjs","names":[],"sources":["../../src/verify/verify.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { fromBase64 } from '@haneullabs/bcs';\n\nimport type { PublicKey, SignatureFlag, SignatureScheme } from '../cryptography/index.js';\nimport { parseSerializedSignature, SIGNATURE_FLAG_TO_SCHEME } from '../cryptography/index.js';\nimport { Ed25519PublicKey } from '../keypairs/ed25519/publickey.js';\nimport { PasskeyPublicKey } from '../keypairs/passkey/publickey.js';\nimport { Secp256k1PublicKey } from '../keypairs/secp256k1/publickey.js';\nimport { Secp256r1PublicKey } from '../keypairs/secp256r1/publickey.js';\nimport { MultiSigPublicKey } from '../multisig/publickey.js';\nimport { ZkLoginPublicIdentifier } from '../zklogin/publickey.js';\nimport type { ClientWithCoreApi } from '../client/core.js';\n\nexport async function verifySignature(\n\tbytes: Uint8Array,\n\tsignature: string,\n\toptions?: {\n\t\taddress?: string;\n\t},\n): Promise<PublicKey> {\n\tconst parsedSignature = parseSignature(signature);\n\n\tif (!(await parsedSignature.publicKey.verify(bytes, parsedSignature.serializedSignature))) {\n\t\tthrow new Error(`Signature is not valid for the provided data`);\n\t}\n\n\tif (options?.address && !parsedSignature.publicKey.verifyAddress(options.address)) {\n\t\tthrow new Error(`Signature is not valid for the provided address`);\n\t}\n\n\treturn parsedSignature.publicKey;\n}\n\nexport async function verifyPersonalMessageSignature(\n\tmessage: Uint8Array,\n\tsignature: string,\n\toptions: { client?: ClientWithCoreApi; address?: string } = {},\n): Promise<PublicKey> {\n\tconst parsedSignature = parseSignature(signature, options);\n\n\tif (\n\t\t!(await parsedSignature.publicKey.verifyPersonalMessage(\n\t\t\tmessage,\n\t\t\tparsedSignature.serializedSignature,\n\t\t))\n\t) {\n\t\tthrow new Error(`Signature is not valid for the provided message`);\n\t}\n\n\tif (options?.address && !parsedSignature.publicKey.verifyAddress(options.address)) {\n\t\tthrow new Error(`Signature is not valid for the provided address`);\n\t}\n\n\treturn parsedSignature.publicKey;\n}\n\nexport async function verifyTransactionSignature(\n\ttransaction: Uint8Array,\n\tsignature: string,\n\toptions: { client?: ClientWithCoreApi; address?: string } = {},\n): Promise<PublicKey> {\n\tconst parsedSignature = parseSignature(signature, options);\n\n\tif (\n\t\t!(await parsedSignature.publicKey.verifyTransaction(\n\t\t\ttransaction,\n\t\t\tparsedSignature.serializedSignature,\n\t\t))\n\t) {\n\t\tthrow new Error(`Signature is not valid for the provided Transaction`);\n\t}\n\n\tif (options?.address && !parsedSignature.publicKey.verifyAddress(options.address)) {\n\t\tthrow new Error(`Signature is not valid for the provided address`);\n\t}\n\n\treturn parsedSignature.publicKey;\n}\n\nfunction parseSignature(signature: string, options: { client?: ClientWithCoreApi } = {}) {\n\tconst parsedSignature = parseSerializedSignature(signature);\n\n\tif (parsedSignature.signatureScheme === 'MultiSig') {\n\t\treturn {\n\t\t\t...parsedSignature,\n\t\t\tpublicKey: new MultiSigPublicKey(parsedSignature.multisig.multisig_pk),\n\t\t};\n\t}\n\n\tconst publicKey = publicKeyFromRawBytes(\n\t\tparsedSignature.signatureScheme,\n\t\tparsedSignature.publicKey,\n\t\toptions,\n\t);\n\treturn {\n\t\t...parsedSignature,\n\t\tpublicKey,\n\t};\n}\n\nexport function publicKeyFromRawBytes(\n\tsignatureScheme: SignatureScheme,\n\tbytes: Uint8Array,\n\toptions: { client?: ClientWithCoreApi; address?: string } = {},\n): PublicKey {\n\tlet publicKey: PublicKey;\n\tswitch (signatureScheme) {\n\t\tcase 'ED25519':\n\t\t\tpublicKey = new Ed25519PublicKey(bytes);\n\t\t\tbreak;\n\t\tcase 'Secp256k1':\n\t\t\tpublicKey = new Secp256k1PublicKey(bytes);\n\t\t\tbreak;\n\t\tcase 'Secp256r1':\n\t\t\tpublicKey = new Secp256r1PublicKey(bytes);\n\t\t\tbreak;\n\t\tcase 'MultiSig':\n\t\t\tpublicKey = new MultiSigPublicKey(bytes);\n\t\t\tbreak;\n\t\tcase 'ZkLogin':\n\t\t\tpublicKey = ZkLoginPublicIdentifier.fromBytes(bytes, options);\n\t\t\tbreak;\n\t\tcase 'Passkey':\n\t\t\tpublicKey = new PasskeyPublicKey(bytes);\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tthrow new Error(`Unsupported signature scheme ${signatureScheme}`);\n\t}\n\n\tif (options.address && publicKey.toSuiAddress() !== options.address) {\n\t\tthrow new Error(`Public key bytes do not match the provided address`);\n\t}\n\n\treturn publicKey;\n}\n\nexport function publicKeyFromSuiBytes(\n\tpublicKey: string | Uint8Array,\n\toptions: { client?: ClientWithCoreApi; address?: string } = {},\n) {\n\tconst bytes = typeof publicKey === 'string' ? fromBase64(publicKey) : publicKey;\n\n\tconst signatureScheme = SIGNATURE_FLAG_TO_SCHEME[bytes[0] as SignatureFlag];\n\n\treturn publicKeyFromRawBytes(signatureScheme, bytes.slice(1), options);\n}\n"],"mappings":";;;;;;;;;;;AAeA,eAAsB,gBACrB,OACA,WACA,SAGqB;CACrB,MAAM,kBAAkB,eAAe,UAAU;AAEjD,KAAI,CAAE,MAAM,gBAAgB,UAAU,OAAO,OAAO,gBAAgB,oBAAoB,CACvF,OAAM,IAAI,MAAM,+CAA+C;AAGhE,KAAI,SAAS,WAAW,CAAC,gBAAgB,UAAU,cAAc,QAAQ,QAAQ,CAChF,OAAM,IAAI,MAAM,kDAAk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UAAU,OAAO,QAAQ;AAC7D;EACD,KAAK;AACJ,eAAY,IAAI,iBAAiB,MAAM;AACvC;EACD,QACC,OAAM,IAAI,MAAM,gCAAgC,kBAAkB;;AAGpE,KAAI,QAAQ,WAAW,UAAU,cAAc,KAAK,QAAQ,QAC3D,OAAM,IAAI,MAAM,qDAAqD;AAGtE,QAAO;;AAGR,SAAgB,sBACf,WACA,UAA4D,EAAE,EAC7D;CACD,MAAM,QAAQ,OAAO,cAAc,WAAW,WAAW,UAAU,GAAG;CAEtE,MAAM,kBAAkB,yBAAyB,MAAM;AAEvD,QAAO,sBAAsB,iBAAiB,MAAM,MAAM,EAAE,EAAE,QAAQ"}
1
+ {"version":3,"file":"verify.mjs","names":[],"sources":["../../src/verify/verify.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { fromBase64 } from '@haneullabs/bcs';\n\nimport type { PublicKey, SignatureFlag, SignatureScheme } from '../cryptography/index.js';\nimport { parseSerializedSignature, SIGNATURE_FLAG_TO_SCHEME } from '../cryptography/index.js';\nimport { Ed25519PublicKey } from '../keypairs/ed25519/publickey.js';\nimport { PasskeyPublicKey } from '../keypairs/passkey/publickey.js';\nimport { Secp256k1PublicKey } from '../keypairs/secp256k1/publickey.js';\nimport { Secp256r1PublicKey } from '../keypairs/secp256r1/publickey.js';\nimport { MultiSigPublicKey } from '../multisig/publickey.js';\nimport { ZkLoginPublicIdentifier } from '../zklogin/publickey.js';\nimport type { ClientWithCoreApi } from '../client/core.js';\n\nexport async function verifySignature(\n\tbytes: Uint8Array,\n\tsignature: string,\n\toptions?: {\n\t\taddress?: string;\n\t},\n): Promise<PublicKey> {\n\tconst parsedSignature = parseSignature(signature);\n\n\tif (!(await parsedSignature.publicKey.verify(bytes, parsedSignature.serializedSignature))) {\n\t\tthrow new Error(`Signature is not valid for the provided data`);\n\t}\n\n\tif (options?.address && !parsedSignature.publicKey.verifyAddress(options.address)) {\n\t\tthrow new Error(`Signature is not valid for the provided address`);\n\t}\n\n\treturn parsedSignature.publicKey;\n}\n\nexport async function verifyPersonalMessageSignature(\n\tmessage: Uint8Array,\n\tsignature: string,\n\toptions: { client?: ClientWithCoreApi; address?: string } = {},\n): Promise<PublicKey> {\n\tconst parsedSignature = parseSignature(signature, options);\n\n\tif (\n\t\t!(await parsedSignature.publicKey.verifyPersonalMessage(\n\t\t\tmessage,\n\t\t\tparsedSignature.serializedSignature,\n\t\t))\n\t) {\n\t\tthrow new Error(`Signature is not valid for the provided message`);\n\t}\n\n\tif (options?.address && !parsedSignature.publicKey.verifyAddress(options.address)) {\n\t\tthrow new Error(`Signature is not valid for the provided address`);\n\t}\n\n\treturn parsedSignature.publicKey;\n}\n\nexport async function verifyTransactionSignature(\n\ttransaction: Uint8Array,\n\tsignature: string,\n\toptions: { client?: ClientWithCoreApi; address?: string } = {},\n): Promise<PublicKey> {\n\tconst parsedSignature = parseSignature(signature, options);\n\n\tif (\n\t\t!(await parsedSignature.publicKey.verifyTransaction(\n\t\t\ttransaction,\n\t\t\tparsedSignature.serializedSignature,\n\t\t))\n\t) {\n\t\tthrow new Error(`Signature is not valid for the provided Transaction`);\n\t}\n\n\tif (options?.address && !parsedSignature.publicKey.verifyAddress(options.address)) {\n\t\tthrow new Error(`Signature is not valid for the provided address`);\n\t}\n\n\treturn parsedSignature.publicKey;\n}\n\nfunction parseSignature(signature: string, options: { client?: ClientWithCoreApi } = {}) {\n\tconst parsedSignature = parseSerializedSignature(signature);\n\n\tif (parsedSignature.signatureScheme === 'MultiSig') {\n\t\treturn {\n\t\t\t...parsedSignature,\n\t\t\tpublicKey: new MultiSigPublicKey(parsedSignature.multisig.multisig_pk),\n\t\t};\n\t}\n\n\tconst publicKey = publicKeyFromRawBytes(\n\t\tparsedSignature.signatureScheme,\n\t\tparsedSignature.publicKey,\n\t\toptions,\n\t);\n\treturn {\n\t\t...parsedSignature,\n\t\tpublicKey,\n\t};\n}\n\nexport function publicKeyFromRawBytes(\n\tsignatureScheme: SignatureScheme,\n\tbytes: Uint8Array,\n\toptions: { client?: ClientWithCoreApi; address?: string } = {},\n): PublicKey {\n\tlet publicKey: PublicKey;\n\tswitch (signatureScheme) {\n\t\tcase 'ED25519':\n\t\t\tpublicKey = new Ed25519PublicKey(bytes);\n\t\t\tbreak;\n\t\tcase 'Secp256k1':\n\t\t\tpublicKey = new Secp256k1PublicKey(bytes);\n\t\t\tbreak;\n\t\tcase 'Secp256r1':\n\t\t\tpublicKey = new Secp256r1PublicKey(bytes);\n\t\t\tbreak;\n\t\tcase 'MultiSig':\n\t\t\tpublicKey = new MultiSigPublicKey(bytes);\n\t\t\tbreak;\n\t\tcase 'ZkLogin':\n\t\t\tpublicKey = ZkLoginPublicIdentifier.fromBytes(bytes, options);\n\t\t\tbreak;\n\t\tcase 'Passkey':\n\t\t\tpublicKey = new PasskeyPublicKey(bytes);\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tthrow new Error(`Unsupported signature scheme ${signatureScheme}`);\n\t}\n\n\tif (options.address && publicKey.toHaneulAddress() !== options.address) {\n\t\tthrow new Error(`Public key bytes do not match the provided address`);\n\t}\n\n\treturn publicKey;\n}\n\nexport function publicKeyFromSuiBytes(\n\tpublicKey: string | Uint8Array,\n\toptions: { client?: ClientWithCoreApi; address?: string } = {},\n) {\n\tconst bytes = typeof publicKey === 'string' ? fromBase64(publicKey) : publicKey;\n\n\tconst signatureScheme = SIGNATURE_FLAG_TO_SCHEME[bytes[0] as SignatureFlag];\n\n\treturn publicKeyFromRawBytes(signatureScheme, bytes.slice(1), options);\n}\n"],"mappings":";;;;;;;;;;;AAeA,eAAsB,gBACrB,OACA,WACA,SAGqB;CACrB,MAAM,kBAAkB,eAAe,UAAU;AAEjD,KAAI,CAAE,MAAM,gBAAgB,UAAU,OAAO,OAAO,gBAAgB,oBAAoB,CACvF,OAAM,IAAI,MAAM,+CAA+C;AAGhE,KAAI,SAAS,WAAW,CAAC,gBAAgB,UAAU,cAAc,QAAQ,QAA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C;EACD,KAAK;AACJ,eAAY,wBAAwB,UAAU,OAAO,QAAQ;AAC7D;EACD,KAAK;AACJ,eAAY,IAAI,iBAAiB,MAAM;AACvC;EACD,QACC,OAAM,IAAI,MAAM,gCAAgC,kBAAkB;;AAGpE,KAAI,QAAQ,WAAW,UAAU,iBAAiB,KAAK,QAAQ,QAC9D,OAAM,IAAI,MAAM,qDAAqD;AAGtE,QAAO;;AAGR,SAAgB,sBACf,WACA,UAA4D,EAAE,EAC7D;CACD,MAAM,QAAQ,OAAO,cAAc,WAAW,WAAW,UAAU,GAAG;CAEtE,MAAM,kBAAkB,yBAAyB,MAAM;AAEvD,QAAO,sBAAsB,iBAAiB,MAAM,MAAM,EAAE,EAAE,QAAQ"}
@@ -32,7 +32,7 @@ declare class ZkLoginPublicIdentifier extends PublicKey {
32
32
  * Checks if two zkLogin public identifiers are equal
33
33
  */
34
34
  equals(publicKey: ZkLoginPublicIdentifier): boolean;
35
- toSuiAddress(): string;
35
+ toHaneulAddress(): string;
36
36
  /**
37
37
  * Return the byte array representation of the zkLogin public identifier
38
38
  */
@@ -1 +1 @@
1
- {"version":3,"file":"publickey.d.mts","names":[],"sources":["../../src/zklogin/publickey.ts"],"sourcesContent":[],"mappings":";;;;;;;AAoBA;;AASyC,cAT5B,uBAAA,SAAgC,SAAA,CASJ;EAAqB,CAAA,OAAA;EAoBrD;;;;EAKO,WAAA,CAAA,KAAA,EAzBI,iBAyBJ,EAAA;IAAA;EAmC0B,CAAA,CAnC1B,EAAA;IAAmE,MAAA,CAAA,EAzBrB,iBAyBqB;EAmCzC,CAAA;EAAsB,OAAA,SAAA,CAAA,KAAA,EAxCvD,UAwCuD,EAAA;IAAA,MAAA;IAAA,OAAA;IAAA;EAiExC,CAAA,CAjEwC,EAAA;IA0BpC,MAAA,CAAA,EA7DZ,iBA6DY;IAyBF,OAAA,CAAA,EAAA,MAAA;IAAX,aAAA,CAAA,EAAA,OAAA;EAcS,CAAA,CAAA,EApG2D,uBAoG3D;EA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AAA;EAkLtC;;;;;;;mBA5CQ,wBAAwB,sBAAsB;;;;iCAOtC,uBAAuB,sBAAsB;;;;iCAgB7C,uBAAuB,sBAAsB;;;;;;iBAqB7D,yBAAA;WAGK;;IAClB"}
@@ -35,18 +35,18 @@ var ZkLoginPublicIdentifier = class ZkLoginPublicIdentifier extends PublicKey {
35
35
  else if (legacyAddress === false) publicKey = new ZkLoginPublicIdentifier(normalizeZkLoginPublicKeyBytes(bytes, false), { client });
36
36
  else if (address) {
37
37
  publicKey = new ZkLoginPublicIdentifier(normalizeZkLoginPublicKeyBytes(bytes, false), { client });
38
- if (publicKey.toSuiAddress() !== address) publicKey = new ZkLoginPublicIdentifier(normalizeZkLoginPublicKeyBytes(bytes, true), { client });
38
+ if (publicKey.toHaneulAddress() !== address) publicKey = new ZkLoginPublicIdentifier(normalizeZkLoginPublicKeyBytes(bytes, true), { client });
39
39
  } else publicKey = new ZkLoginPublicIdentifier(bytes, { client });
40
- if (address && publicKey.toSuiAddress() !== address) throw new Error("Public key bytes do not match the provided address");
40
+ if (address && publicKey.toHaneulAddress() !== address) throw new Error("Public key bytes do not match the provided address");
41
41
  return publicKey;
42
42
  }
43
43
  static fromProof(address, proof) {
44
44
  const { issBase64Details, addressSeed } = proof;
45
45
  const iss = extractClaimValue(issBase64Details, "iss");
46
46
  const legacyPublicKey = toZkLoginPublicIdentifier(BigInt(addressSeed), iss, { legacyAddress: true });
47
- if (legacyPublicKey.toSuiAddress() === address) return legacyPublicKey;
47
+ if (legacyPublicKey.toHaneulAddress() === address) return legacyPublicKey;
48
48
  const publicKey = toZkLoginPublicIdentifier(BigInt(addressSeed), iss, { legacyAddress: false });
49
- if (publicKey.toSuiAddress() !== address) throw new Error("Proof does not match address");
49
+ if (publicKey.toHaneulAddress() !== address) throw new Error("Proof does not match address");
50
50
  return publicKey;
51
51
  }
52
52
  /**
@@ -55,9 +55,9 @@ var ZkLoginPublicIdentifier = class ZkLoginPublicIdentifier extends PublicKey {
55
55
  equals(publicKey) {
56
56
  return super.equals(publicKey);
57
57
  }
58
- toSuiAddress() {
58
+ toHaneulAddress() {
59
59
  if (this.#legacyAddress) return this.#toLegacyAddress();
60
- return super.toSuiAddress();
60
+ return super.toHaneulAddress();
61
61
  }
62
62
  #toLegacyAddress() {
63
63
  const legacyBytes = normalizeZkLoginPublicKeyBytes(this.#data, true);
@@ -90,7 +90,7 @@ var ZkLoginPublicIdentifier = class ZkLoginPublicIdentifier extends PublicKey {
90
90
  verifyPersonalMessage(message, signature) {
91
91
  const parsedSignature = parseSerializedZkLoginSignature(signature);
92
92
  return graphqlVerifyZkLoginSignature({
93
- address: new ZkLoginPublicIdentifier(parsedSignature.publicKey).toSuiAddress(),
93
+ address: new ZkLoginPublicIdentifier(parsedSignature.publicKey).toHaneulAddress(),
94
94
  bytes: toBase64(message),
95
95
  signature: parsedSignature.serializedSignature,
96
96
  intentScope: "PersonalMessage",
@@ -103,7 +103,7 @@ var ZkLoginPublicIdentifier = class ZkLoginPublicIdentifier extends PublicKey {
103
103
  verifyTransaction(transaction, signature) {
104
104
  const parsedSignature = parseSerializedZkLoginSignature(signature);
105
105
  return graphqlVerifyZkLoginSignature({
106
- address: new ZkLoginPublicIdentifier(parsedSignature.publicKey).toSuiAddress(),
106
+ address: new ZkLoginPublicIdentifier(parsedSignature.publicKey).toHaneulAddress(),
107
107
  bytes: toBase64(transaction),
108
108
  signature: parsedSignature.serializedSignature,
109
109
  intentScope: "TransactionData",
@@ -114,7 +114,7 @@ var ZkLoginPublicIdentifier = class ZkLoginPublicIdentifier extends PublicKey {
114
114
  * Verifies that the public key is associated with the provided address
115
115
  */
116
116
  verifyAddress(address) {
117
- return address === super.toSuiAddress() || address === this.#toLegacyAddress();
117
+ return address === super.toHaneulAddress() || address === this.#toLegacyAddress();
118
118
  }
119
119
  };
120
120
  function toZkLoginPublicIdentifier(addressSeed, iss, options) {
@@ -1 +1 @@
1
- {"version":3,"file":"publickey.mjs","names":["#client","#data","#legacyAddress","#toLegacyAddress"],"sources":["../../src/zklogin/publickey.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { fromBase64, toBase64, toHex } from '@haneullabs/bcs';\nimport { blake2b } from '@noble/hashes/blake2.js';\nimport { bytesToHex } from '@noble/hashes/utils.js';\n\nimport { PublicKey } from '../cryptography/publickey.js';\nimport type { PublicKeyInitData } from '../cryptography/publickey.js';\nimport { SIGNATURE_SCHEME_TO_FLAG } from '../cryptography/signature-scheme.js';\nimport { normalizeHaneulAddress, HANEUL_ADDRESS_LENGTH } from '../utils/haneul-types.js';\nimport type { ZkLoginSignatureInputs } from './bcs.js';\nimport { extractClaimValue } from './jwt-utils.js';\nimport { parseZkLoginSignature } from './signature.js';\nimport { normalizeZkLoginIssuer, toBigEndianBytes, toPaddedBigEndianBytes } from './utils.js';\nimport type { ClientWithCoreApi } from '../client/core.js';\n\n/**\n * A zkLogin public identifier\n */\nexport class ZkLoginPublicIdentifier extends PublicKey {\n\t#data: Uint8Array<ArrayBuffer>;\n\t#client?: ClientWithCoreApi;\n\t#legacyAddress: boolean;\n\n\t/**\n\t * Create a new ZkLoginPublicIdentifier object\n\t * @param value zkLogin public identifier as buffer or base-64 encoded string\n\t */\n\tconstructor(value: PublicKeyInitData, { client }: { client?: ClientWithCoreApi } = {}) {\n\t\tsuper();\n\n\t\tthis.#client = client;\n\n\t\tif (typeof value === 'string') {\n\t\t\tthis.#data = fromBase64(value);\n\t\t} else if (value instanceof Uint8Array) {\n\t\t\tthis.#data = value as Uint8Array<ArrayBuffer>;\n\t\t} else {\n\t\t\tthis.#data = Uint8Array.from(value);\n\t\t}\n\t\tthis.#legacyAddress = this.#data.length !== this.#data[0] + 1 + 32;\n\n\t\tif (this.#legacyAddress) {\n\t\t\tthis.#data = normalizeZkLoginPublicKeyBytes(this.#data, false);\n\t\t}\n\t}\n\n\tstatic fromBytes(\n\t\tbytes: Uint8Array,\n\t\t{\n\t\t\tclient,\n\t\t\taddress,\n\t\t\tlegacyAddress,\n\t\t}: { client?: ClientWithCoreApi; address?: string; legacyAddress?: boolean } = {},\n\t) {\n\t\tlet publicKey: ZkLoginPublicIdentifier;\n\n\t\tif (legacyAddress === true) {\n\t\t\tpublicKey = new ZkLoginPublicIdentifier(normalizeZkLoginPublicKeyBytes(bytes, true), {\n\t\t\t\tclient,\n\t\t\t});\n\t\t} else if (legacyAddress === false) {\n\t\t\tpublicKey = new ZkLoginPublicIdentifier(normalizeZkLoginPublicKeyBytes(bytes, false), {\n\t\t\t\tclient,\n\t\t\t});\n\t\t} else if (address) {\n\t\t\tpublicKey = new ZkLoginPublicIdentifier(normalizeZkLoginPublicKeyBytes(bytes, false), {\n\t\t\t\tclient,\n\t\t\t});\n\n\t\t\tif (publicKey.toSuiAddress() !== address) {\n\t\t\t\tpublicKey = new ZkLoginPublicIdentifier(normalizeZkLoginPublicKeyBytes(bytes, true), {\n\t\t\t\t\tclient,\n\t\t\t\t});\n\t\t\t}\n\t\t} else {\n\t\t\tpublicKey = new ZkLoginPublicIdentifier(bytes, {\n\t\t\t\tclient,\n\t\t\t});\n\t\t}\n\n\t\tif (address && publicKey.toSuiAddress() !== address) {\n\t\t\tthrow new Error('Public key bytes do not match the provided address');\n\t\t}\n\n\t\treturn publicKey;\n\t}\n\n\tstatic fromProof(address: string, proof: ZkLoginSignatureInputs) {\n\t\tconst { issBase64Details, addressSeed } = proof;\n\t\tconst iss = extractClaimValue<string>(issBase64Details, 'iss');\n\n\t\tconst legacyPublicKey = toZkLoginPublicIdentifier(BigInt(addressSeed), iss, {\n\t\t\tlegacyAddress: true,\n\t\t});\n\n\t\tif (legacyPublicKey.toSuiAddress() === address) {\n\t\t\treturn legacyPublicKey;\n\t\t}\n\n\t\tconst publicKey = toZkLoginPublicIdentifier(BigInt(addressSeed), iss, {\n\t\t\tlegacyAddress: false,\n\t\t});\n\n\t\tif (publicKey.toSuiAddress() !== address) {\n\t\t\tthrow new Error('Proof does not match address');\n\t\t}\n\n\t\treturn publicKey;\n\t}\n\n\t/**\n\t * Checks if two zkLogin public identifiers are equal\n\t */\n\toverride equals(publicKey: ZkLoginPublicIdentifier): boolean {\n\t\treturn super.equals(publicKey);\n\t}\n\n\toverride toSuiAddress(): string {\n\t\tif (this.#legacyAddress) {\n\t\t\treturn this.#toLegacyAddress();\n\t\t}\n\n\t\treturn super.toSuiAddress();\n\t}\n\n\t#toLegacyAddress() {\n\t\tconst legacyBytes = normalizeZkLoginPublicKeyBytes(this.#data, true);\n\t\tconst addressBytes = new Uint8Array(legacyBytes.length + 1);\n\t\taddressBytes[0] = this.flag();\n\t\taddressBytes.set(legacyBytes, 1);\n\t\treturn normalizeHaneulAddress(\n\t\t\tbytesToHex(blake2b(addressBytes, { dkLen: 32 })).slice(0, HANEUL_ADDRESS_LENGTH * 2),\n\t\t);\n\t}\n\n\t/**\n\t * Return the byte array representation of the zkLogin public identifier\n\t */\n\ttoRawBytes(): Uint8Array<ArrayBuffer> {\n\t\treturn this.#data;\n\t}\n\n\t/**\n\t * Return the Haneul address associated with this ZkLogin public identifier\n\t */\n\tflag(): number {\n\t\treturn SIGNATURE_SCHEME_TO_FLAG['ZkLogin'];\n\t}\n\n\t/**\n\t * Verifies that the signature is valid for for the provided message\n\t */\n\tasync verify(_message: Uint8Array, _signature: Uint8Array | string): Promise<boolean> {\n\t\tthrow Error('does not support');\n\t}\n\n\t/**\n\t * Verifies that the signature is valid for for the provided PersonalMessage\n\t */\n\tverifyPersonalMessage(message: Uint8Array, signature: Uint8Array | string): Promise<boolean> {\n\t\tconst parsedSignature = parseSerializedZkLoginSignature(signature);\n\t\tconst address = new ZkLoginPublicIdentifier(parsedSignature.publicKey).toSuiAddress();\n\n\t\treturn graphqlVerifyZkLoginSignature({\n\t\t\taddress: address,\n\t\t\tbytes: toBase64(message),\n\t\t\tsignature: parsedSignature.serializedSignature,\n\t\t\tintentScope: 'PersonalMessage',\n\t\t\tclient: this.#client,\n\t\t});\n\t}\n\n\t/**\n\t * Verifies that the signature is valid for for the provided Transaction\n\t */\n\tverifyTransaction(transaction: Uint8Array, signature: Uint8Array | string): Promise<boolean> {\n\t\tconst parsedSignature = parseSerializedZkLoginSignature(signature);\n\t\tconst address = new ZkLoginPublicIdentifier(parsedSignature.publicKey).toSuiAddress();\n\t\treturn graphqlVerifyZkLoginSignature({\n\t\t\taddress: address,\n\t\t\tbytes: toBase64(transaction),\n\t\t\tsignature: parsedSignature.serializedSignature,\n\t\t\tintentScope: 'TransactionData',\n\t\t\tclient: this.#client,\n\t\t});\n\t}\n\n\t/**\n\t * Verifies that the public key is associated with the provided address\n\t */\n\toverride verifyAddress(address: string): boolean {\n\t\treturn address === super.toSuiAddress() || address === this.#toLegacyAddress();\n\t}\n}\n\n// Derive the public identifier for zklogin based on address seed and iss.\nexport function toZkLoginPublicIdentifier(\n\taddressSeed: bigint,\n\tiss: string,\n\toptions: { client?: ClientWithCoreApi; legacyAddress: boolean },\n): ZkLoginPublicIdentifier {\n\tif (options.legacyAddress === undefined) {\n\t\tthrow new Error('legacyAddress parameter must be specified');\n\t}\n\t// Consists of iss_bytes_len || iss_bytes || padded_32_byte_address_seed.\n\tconst addressSeedBytesBigEndian = options.legacyAddress\n\t\t? toBigEndianBytes(addressSeed, 32)\n\t\t: toPaddedBigEndianBytes(addressSeed, 32);\n\n\tconst issBytes = new TextEncoder().encode(normalizeZkLoginIssuer(iss));\n\tconst tmp = new Uint8Array(1 + issBytes.length + addressSeedBytesBigEndian.length);\n\ttmp.set([issBytes.length], 0);\n\ttmp.set(issBytes, 1);\n\ttmp.set(addressSeedBytesBigEndian, 1 + issBytes.length);\n\treturn new ZkLoginPublicIdentifier(tmp, options);\n}\n\nfunction normalizeZkLoginPublicKeyBytes(bytes: Uint8Array, legacyAddress: boolean) {\n\tconst issByteLength = bytes[0] + 1;\n\tconst addressSeed = BigInt(`0x${toHex(bytes.slice(issByteLength))}`);\n\tconst seedBytes = legacyAddress\n\t\t? toBigEndianBytes(addressSeed, 32)\n\t\t: toPaddedBigEndianBytes(addressSeed, 32);\n\tconst data = new Uint8Array(issByteLength + seedBytes.length);\n\tdata.set(bytes.slice(0, issByteLength), 0);\n\tdata.set(seedBytes, issByteLength);\n\treturn data;\n}\n\nasync function graphqlVerifyZkLoginSignature({\n\taddress,\n\tbytes,\n\tsignature,\n\tintentScope,\n\tclient,\n}: {\n\taddress: string;\n\tbytes: string;\n\tsignature: string;\n\tintentScope: 'PersonalMessage' | 'TransactionData';\n\tclient?: ClientWithCoreApi;\n}) {\n\tif (!client) {\n\t\tthrow new Error(\n\t\t\t'A Haneul Client (GRPC, GraphQL, or JSON RPC) is required to verify zkLogin signatures',\n\t\t);\n\t}\n\tconst resp = await client.core.verifyZkLoginSignature({\n\t\tbytes,\n\t\tsignature,\n\t\tintentScope,\n\t\taddress: address,\n\t});\n\n\treturn resp.success === true && resp.errors.length === 0;\n}\n\nexport function parseSerializedZkLoginSignature(signature: Uint8Array | string) {\n\tconst bytes = typeof signature === 'string' ? fromBase64(signature) : signature;\n\n\tif (bytes[0] !== SIGNATURE_SCHEME_TO_FLAG.ZkLogin) {\n\t\tthrow new Error('Invalid signature scheme');\n\t}\n\n\tconst signatureBytes = bytes.slice(1);\n\tconst { inputs, maxEpoch, userSignature } = parseZkLoginSignature(signatureBytes);\n\tconst { issBase64Details, addressSeed } = inputs;\n\tconst iss = extractClaimValue<string>(issBase64Details, 'iss');\n\tconst publicIdentifier = toZkLoginPublicIdentifier(BigInt(addressSeed), iss, {\n\t\tlegacyAddress: false,\n\t});\n\treturn {\n\t\tserializedSignature: toBase64(bytes),\n\t\tsignatureScheme: 'ZkLogin' as const,\n\t\tzkLogin: {\n\t\t\tinputs,\n\t\t\tmaxEpoch,\n\t\t\tuserSignature,\n\t\t\tiss,\n\t\t\taddressSeed: BigInt(addressSeed),\n\t\t},\n\t\tsignature: bytes,\n\t\tpublicKey: publicIdentifier.toRawBytes(),\n\t};\n}\n"],"mappings":";;;;;;;;;;;;;;AAoBA,IAAa,0BAAb,MAAa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kBAAkB,sBADrB,MAAM,MAAM,EAAE,CAC4C;CACjF,MAAM,EAAE,kBAAkB,gBAAgB;CAC1C,MAAM,MAAM,kBAA0B,kBAAkB,MAAM;CAC9D,MAAM,mBAAmB,0BAA0B,OAAO,YAAY,EAAE,KAAK,EAC5E,eAAe,OACf,CAAC;AACF,QAAO;EACN,qBAAqB,SAAS,MAAM;EACpC,iBAAiB;EACjB,SAAS;GACR;GACA;GACA;GACA;GACA,aAAa,OAAO,YAAY;GAChC;EACD,WAAW;EACX,WAAW,iBAAiB,YAAY;EACxC"}
1
+ {"version":3,"file":"publickey.mjs","names":["#client","#data","#legacyAddress","#toLegacyAddress"],"sources":["../../src/zklogin/publickey.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { fromBase64, toBase64, toHex } from '@haneullabs/bcs';\nimport { blake2b } from '@noble/hashes/blake2.js';\nimport { bytesToHex } from '@noble/hashes/utils.js';\n\nimport { PublicKey } from '../cryptography/publickey.js';\nimport type { PublicKeyInitData } from '../cryptography/publickey.js';\nimport { SIGNATURE_SCHEME_TO_FLAG } from '../cryptography/signature-scheme.js';\nimport { normalizeHaneulAddress, HANEUL_ADDRESS_LENGTH } from '../utils/haneul-types.js';\nimport type { ZkLoginSignatureInputs } from './bcs.js';\nimport { extractClaimValue } from './jwt-utils.js';\nimport { parseZkLoginSignature } from './signature.js';\nimport { normalizeZkLoginIssuer, toBigEndianBytes, toPaddedBigEndianBytes } from './utils.js';\nimport type { ClientWithCoreApi } from '../client/core.js';\n\n/**\n * A zkLogin public identifier\n */\nexport class ZkLoginPublicIdentifier extends PublicKey {\n\t#data: Uint8Array<ArrayBuffer>;\n\t#client?: ClientWithCoreApi;\n\t#legacyAddress: boolean;\n\n\t/**\n\t * Create a new ZkLoginPublicIdentifier object\n\t * @param value zkLogin public identifier as buffer or base-64 encoded string\n\t */\n\tconstructor(value: PublicKeyInitData, { client }: { client?: ClientWithCoreApi } = {}) {\n\t\tsuper();\n\n\t\tthis.#client = client;\n\n\t\tif (typeof value === 'string') {\n\t\t\tthis.#data = fromBase64(value);\n\t\t} else if (value instanceof Uint8Array) {\n\t\t\tthis.#data = value as Uint8Array<ArrayBuffer>;\n\t\t} else {\n\t\t\tthis.#data = Uint8Array.from(value);\n\t\t}\n\t\tthis.#legacyAddress = this.#data.length !== this.#data[0] + 1 + 32;\n\n\t\tif (this.#legacyAddress) {\n\t\t\tthis.#data = normalizeZkLoginPublicKeyBytes(this.#data, false);\n\t\t}\n\t}\n\n\tstatic fromBytes(\n\t\tbytes: Uint8Array,\n\t\t{\n\t\t\tclient,\n\t\t\taddress,\n\t\t\tlegacyAddress,\n\t\t}: { client?: ClientWithCoreApi; address?: string; legacyAddress?: boolean } = {},\n\t) {\n\t\tlet publicKey: ZkLoginPublicIdentifier;\n\n\t\tif (legacyAddress === true) {\n\t\t\tpublicKey = new ZkLoginPublicIdentifier(normalizeZkLoginPublicKeyBytes(bytes, true), {\n\t\t\t\tclient,\n\t\t\t});\n\t\t} else if (legacyAddress === false) {\n\t\t\tpublicKey = new ZkLoginPublicIdentifier(normalizeZkLoginPublicKeyBytes(bytes, false), {\n\t\t\t\tclient,\n\t\t\t});\n\t\t} else if (address) {\n\t\t\tpublicKey = new ZkLoginPublicIdentifier(normalizeZkLoginPublicKeyBytes(bytes, false), {\n\t\t\t\tclient,\n\t\t\t});\n\n\t\t\tif (publicKey.toHaneulAddress() !== address) {\n\t\t\t\tpublicKey = new ZkLoginPublicIdentifier(normalizeZkLoginPublicKeyBytes(bytes, true), {\n\t\t\t\t\tclient,\n\t\t\t\t});\n\t\t\t}\n\t\t} else {\n\t\t\tpublicKey = new ZkLoginPublicIdentifier(bytes, {\n\t\t\t\tclient,\n\t\t\t});\n\t\t}\n\n\t\tif (address && publicKey.toHaneulAddress() !== address) {\n\t\t\tthrow new Error('Public key bytes do not match the provided address');\n\t\t}\n\n\t\treturn publicKey;\n\t}\n\n\tstatic fromProof(address: string, proof: ZkLoginSignatureInputs) {\n\t\tconst { issBase64Details, addressSeed } = proof;\n\t\tconst iss = extractClaimValue<string>(issBase64Details, 'iss');\n\n\t\tconst legacyPublicKey = toZkLoginPublicIdentifier(BigInt(addressSeed), iss, {\n\t\t\tlegacyAddress: true,\n\t\t});\n\n\t\tif (legacyPublicKey.toHaneulAddress() === address) {\n\t\t\treturn legacyPublicKey;\n\t\t}\n\n\t\tconst publicKey = toZkLoginPublicIdentifier(BigInt(addressSeed), iss, {\n\t\t\tlegacyAddress: false,\n\t\t});\n\n\t\tif (publicKey.toHaneulAddress() !== address) {\n\t\t\tthrow new Error('Proof does not match address');\n\t\t}\n\n\t\treturn publicKey;\n\t}\n\n\t/**\n\t * Checks if two zkLogin public identifiers are equal\n\t */\n\toverride equals(publicKey: ZkLoginPublicIdentifier): boolean {\n\t\treturn super.equals(publicKey);\n\t}\n\n\toverride toHaneulAddress(): string {\n\t\tif (this.#legacyAddress) {\n\t\t\treturn this.#toLegacyAddress();\n\t\t}\n\n\t\treturn super.toHaneulAddress();\n\t}\n\n\t#toLegacyAddress() {\n\t\tconst legacyBytes = normalizeZkLoginPublicKeyBytes(this.#data, true);\n\t\tconst addressBytes = new Uint8Array(legacyBytes.length + 1);\n\t\taddressBytes[0] = this.flag();\n\t\taddressBytes.set(legacyBytes, 1);\n\t\treturn normalizeHaneulAddress(\n\t\t\tbytesToHex(blake2b(addressBytes, { dkLen: 32 })).slice(0, HANEUL_ADDRESS_LENGTH * 2),\n\t\t);\n\t}\n\n\t/**\n\t * Return the byte array representation of the zkLogin public identifier\n\t */\n\ttoRawBytes(): Uint8Array<ArrayBuffer> {\n\t\treturn this.#data;\n\t}\n\n\t/**\n\t * Return the Haneul address associated with this ZkLogin public identifier\n\t */\n\tflag(): number {\n\t\treturn SIGNATURE_SCHEME_TO_FLAG['ZkLogin'];\n\t}\n\n\t/**\n\t * Verifies that the signature is valid for for the provided message\n\t */\n\tasync verify(_message: Uint8Array, _signature: Uint8Array | string): Promise<boolean> {\n\t\tthrow Error('does not support');\n\t}\n\n\t/**\n\t * Verifies that the signature is valid for for the provided PersonalMessage\n\t */\n\tverifyPersonalMessage(message: Uint8Array, signature: Uint8Array | string): Promise<boolean> {\n\t\tconst parsedSignature = parseSerializedZkLoginSignature(signature);\n\t\tconst address = new ZkLoginPublicIdentifier(parsedSignature.publicKey).toHaneulAddress();\n\n\t\treturn graphqlVerifyZkLoginSignature({\n\t\t\taddress: address,\n\t\t\tbytes: toBase64(message),\n\t\t\tsignature: parsedSignature.serializedSignature,\n\t\t\tintentScope: 'PersonalMessage',\n\t\t\tclient: this.#client,\n\t\t});\n\t}\n\n\t/**\n\t * Verifies that the signature is valid for for the provided Transaction\n\t */\n\tverifyTransaction(transaction: Uint8Array, signature: Uint8Array | string): Promise<boolean> {\n\t\tconst parsedSignature = parseSerializedZkLoginSignature(signature);\n\t\tconst address = new ZkLoginPublicIdentifier(parsedSignature.publicKey).toHaneulAddress();\n\t\treturn graphqlVerifyZkLoginSignature({\n\t\t\taddress: address,\n\t\t\tbytes: toBase64(transaction),\n\t\t\tsignature: parsedSignature.serializedSignature,\n\t\t\tintentScope: 'TransactionData',\n\t\t\tclient: this.#client,\n\t\t});\n\t}\n\n\t/**\n\t * Verifies that the public key is associated with the provided address\n\t */\n\toverride verifyAddress(address: string): boolean {\n\t\treturn address === super.toHaneulAddress() || address === this.#toLegacyAddress();\n\t}\n}\n\n// Derive the public identifier for zklogin based on address seed and iss.\nexport function toZkLoginPublicIdentifier(\n\taddressSeed: bigint,\n\tiss: string,\n\toptions: { client?: ClientWithCoreApi; legacyAddress: boolean },\n): ZkLoginPublicIdentifier {\n\tif (options.legacyAddress === undefined) {\n\t\tthrow new Error('legacyAddress parameter must be specified');\n\t}\n\t// Consists of iss_bytes_len || iss_bytes || padded_32_byte_address_seed.\n\tconst addressSeedBytesBigEndian = options.legacyAddress\n\t\t? toBigEndianBytes(addressSeed, 32)\n\t\t: toPaddedBigEndianBytes(addressSeed, 32);\n\n\tconst issBytes = new TextEncoder().encode(normalizeZkLoginIssuer(iss));\n\tconst tmp = new Uint8Array(1 + issBytes.length + addressSeedBytesBigEndian.length);\n\ttmp.set([issBytes.length], 0);\n\ttmp.set(issBytes, 1);\n\ttmp.set(addressSeedBytesBigEndian, 1 + issBytes.length);\n\treturn new ZkLoginPublicIdentifier(tmp, options);\n}\n\nfunction normalizeZkLoginPublicKeyBytes(bytes: Uint8Array, legacyAddress: boolean) {\n\tconst issByteLength = bytes[0] + 1;\n\tconst addressSeed = BigInt(`0x${toHex(bytes.slice(issByteLength))}`);\n\tconst seedBytes = legacyAddress\n\t\t? toBigEndianBytes(addressSeed, 32)\n\t\t: toPaddedBigEndianBytes(addressSeed, 32);\n\tconst data = new Uint8Array(issByteLength + seedBytes.length);\n\tdata.set(bytes.slice(0, issByteLength), 0);\n\tdata.set(seedBytes, issByteLength);\n\treturn data;\n}\n\nasync function graphqlVerifyZkLoginSignature({\n\taddress,\n\tbytes,\n\tsignature,\n\tintentScope,\n\tclient,\n}: {\n\taddress: string;\n\tbytes: string;\n\tsignature: string;\n\tintentScope: 'PersonalMessage' | 'TransactionData';\n\tclient?: ClientWithCoreApi;\n}) {\n\tif (!client) {\n\t\tthrow new Error(\n\t\t\t'A Haneul Client (GRPC, GraphQL, or JSON RPC) is required to verify zkLogin signatures',\n\t\t);\n\t}\n\tconst resp = await client.core.verifyZkLoginSignature({\n\t\tbytes,\n\t\tsignature,\n\t\tintentScope,\n\t\taddress: address,\n\t});\n\n\treturn resp.success === true && resp.errors.length === 0;\n}\n\nexport function parseSerializedZkLoginSignature(signature: Uint8Array | string) {\n\tconst bytes = typeof signature === 'string' ? fromBase64(signature) : signature;\n\n\tif (bytes[0] !== SIGNATURE_SCHEME_TO_FLAG.ZkLogin) {\n\t\tthrow new Error('Invalid signature scheme');\n\t}\n\n\tconst signatureBytes = bytes.slice(1);\n\tconst { inputs, maxEpoch, userSignature } = parseZkLoginSignature(signatureBytes);\n\tconst { issBase64Details, addressSeed } = inputs;\n\tconst iss = extractClaimValue<string>(issBase64Details, 'iss');\n\tconst publicIdentifier = toZkLoginPublicIdentifier(BigInt(addressSeed), iss, {\n\t\tlegacyAddress: false,\n\t});\n\treturn {\n\t\tserializedSignature: toBase64(bytes),\n\t\tsignatureScheme: 'ZkLogin' as const,\n\t\tzkLogin: {\n\t\t\tinputs,\n\t\t\tmaxEpoch,\n\t\t\tuserSignature,\n\t\t\tiss,\n\t\t\taddressSeed: BigInt(addressSeed),\n\t\t},\n\t\tsignature: bytes,\n\t\tpublicKey: publicIdentifier.toRawBytes(),\n\t};\n}\n"],"mappings":";;;;;;;;;;;;;;AAoBA,IAAa,0BAAb,MAAa,gCAAgC,UAAU;CACtD;CACA;CACA;;;;;CAMA,YAAY,OAA0B,EAAE,WAA2C,EAAE,EAAE;AACtF,SAAO;AAEP,QAAKA,SAAU;AAEf,MAAI,OAAO,UAAU,SACpB,OAAKC,OAAQ,WAAW,MAAM;WACpB,iBAAiB,WAC3B,OAAKA,OAAQ;MAEb,OAAKA,OAAQ,WAAW,KAAK,MAAM;AAEpC,QAAKC,gBAAiB,MAAKD,KAAM,WAAW,MAAKA,KAAM,KAAK,IAAI;AAEhE,MAAI,MAAKC,cACR,OAAKD,OAAQ,+BAA+B,MAAKA,MAAO,MAAM;;CAIhE,OAAO,UACN,OACA,EACC,QACA,SACA,kBAC8E,EAAE,EAChF;EACD,IAAI;AAEJ,MAAI,kBAAkB,KACrB,aAAY,IAAI,wBAAwB,+BAA+B,OAAO,KAAK,EAAE,EACpF,QACA,CAAC;WACQ,kBAAkB,MAC5B,aAAY,IAAI,wBAAwB,+BAA+B,OAAO,MAAM,EAAE,EACrF,QACA,CAAC;WACQ,SAAS;AACnB,eAAY,IAAI,wBAAwB,+BAA+B,OAAO,MAAM,EAAE,EACrF,QACA,CAAC;AAEF,OAAI,UAAU,iBAAiB,KAAK,QACnC,aAAY,IAAI,wBAAwB,+BAA+B,OAAO,KAAK,EAAE,EACpF,QACA,CAAC;QAG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AI,WAAW,cAAc;AAClC,QAAO;;AAGR,eAAe,8BAA8B,EAC5C,SACA,OACA,WACA,aACA,UAOE;AACF,KAAI,CAAC,OACJ,OAAM,IAAI,MACT,wFACA;CAEF,MAAM,OAAO,MAAM,OAAO,KAAK,uBAAuB;EACrD;EACA;EACA;EACS;EACT,CAAC;AAEF,QAAO,KAAK,YAAY,QAAQ,KAAK,OAAO,WAAW;;AAGxD,SAAgB,gCAAgC,WAAgC;CAC/E,MAAM,QAAQ,OAAO,cAAc,WAAW,WAAW,UAAU,GAAG;AAEtE,KAAI,MAAM,OAAO,yBAAyB,QACzC,OAAM,IAAI,MAAM,2BAA2B;CAI5C,MAAM,EAAE,QAAQ,UAAU,kBAAkB,sBADrB,MAAM,MAAM,EAAE,CAC4C;CACjF,MAAM,EAAE,kBAAkB,gBAAgB;CAC1C,MAAM,MAAM,kBAA0B,kBAAkB,MAAM;CAC9D,MAAM,mBAAmB,0BAA0B,OAAO,YAAY,EAAE,KAAK,EAC5E,eAAe,OACf,CAAC;AACF,QAAO;EACN,qBAAqB,SAAS,MAAM;EACpC,iBAAiB;EACjB,SAAS;GACR;GACA;GACA;GACA;GACA,aAAa,OAAO,YAAY;GAChC;EACD,WAAW;EACX,WAAW,iBAAiB,YAAY;EACxC"}
package/package.json CHANGED
@@ -1,200 +1,200 @@
1
1
  {
2
- "name": "@haneullabs/haneul",
3
- "author": "Haneul Labs <build@haneul-labs.com>",
4
- "description": "Haneul TypeScript API",
5
- "homepage": "https://sdk.haneul-labs.com",
6
- "version": "2.4.0",
7
- "license": "Apache-2.0",
8
- "sideEffects": false,
9
- "files": [
10
- "CHANGELOG.md",
11
- "LICENSE",
12
- "README.md",
13
- "bcs",
14
- "builder",
15
- "client",
16
- "cryptography",
17
- "dist",
18
- "experimental",
19
- "faucet",
20
- "graphql",
21
- "grpc",
22
- "jsonRpc",
23
- "keypairs",
24
- "multisig",
25
- "src",
26
- "transactions",
27
- "utils",
28
- "verify",
29
- "zklogin"
30
- ],
31
- "engines": {
32
- "node": ">=22"
33
- },
34
- "type": "module",
35
- "exports": {
36
- "./bcs": {
37
- "types": "./dist/bcs/index.d.mts",
38
- "import": "./dist/bcs/index.mjs",
39
- "default": "./dist/bcs/index.mjs"
40
- },
41
- "./client": {
42
- "types": "./dist/client/index.d.mts",
43
- "import": "./dist/client/index.mjs",
44
- "default": "./dist/client/index.mjs"
45
- },
46
- "./cryptography": {
47
- "types": "./dist/cryptography/index.d.mts",
48
- "import": "./dist/cryptography/index.mjs",
49
- "default": "./dist/cryptography/index.mjs"
50
- },
51
- "./faucet": {
52
- "types": "./dist/faucet/index.d.mts",
53
- "import": "./dist/faucet/index.mjs",
54
- "default": "./dist/faucet/index.mjs"
55
- },
56
- "./graphql": {
57
- "types": "./dist/graphql/index.d.mts",
58
- "import": "./dist/graphql/index.mjs",
59
- "default": "./dist/graphql/index.mjs"
60
- },
61
- "./grpc": {
62
- "types": "./dist/grpc/index.d.mts",
63
- "import": "./dist/grpc/index.mjs",
64
- "default": "./dist/grpc/index.mjs"
65
- },
66
- "./jsonRpc": {
67
- "types": "./dist/jsonRpc/index.d.mts",
68
- "import": "./dist/jsonRpc/index.mjs",
69
- "default": "./dist/jsonRpc/index.mjs"
70
- },
71
- "./keypairs/ed25519": {
72
- "types": "./dist/keypairs/ed25519/index.d.mts",
73
- "import": "./dist/keypairs/ed25519/index.mjs",
74
- "default": "./dist/keypairs/ed25519/index.mjs"
75
- },
76
- "./keypairs/secp256k1": {
77
- "types": "./dist/keypairs/secp256k1/index.d.mts",
78
- "import": "./dist/keypairs/secp256k1/index.mjs",
79
- "default": "./dist/keypairs/secp256k1/index.mjs"
80
- },
81
- "./keypairs/secp256r1": {
82
- "types": "./dist/keypairs/secp256r1/index.d.mts",
83
- "import": "./dist/keypairs/secp256r1/index.mjs",
84
- "default": "./dist/keypairs/secp256r1/index.mjs"
85
- },
86
- "./keypairs/passkey": {
87
- "types": "./dist/keypairs/passkey/index.d.mts",
88
- "import": "./dist/keypairs/passkey/index.mjs",
89
- "default": "./dist/keypairs/passkey/index.mjs"
90
- },
91
- "./multisig": {
92
- "types": "./dist/multisig/index.d.mts",
93
- "import": "./dist/multisig/index.mjs",
94
- "default": "./dist/multisig/index.mjs"
95
- },
96
- "./transactions": {
97
- "types": "./dist/transactions/index.d.mts",
98
- "import": "./dist/transactions/index.mjs",
99
- "default": "./dist/transactions/index.mjs"
100
- },
101
- "./utils": {
102
- "types": "./dist/utils/index.d.mts",
103
- "import": "./dist/utils/index.mjs",
104
- "default": "./dist/utils/index.mjs"
105
- },
106
- "./verify": {
107
- "types": "./dist/verify/index.d.mts",
108
- "import": "./dist/verify/index.mjs",
109
- "default": "./dist/verify/index.mjs"
110
- },
111
- "./zklogin": {
112
- "types": "./dist/zklogin/index.d.mts",
113
- "import": "./dist/zklogin/index.mjs",
114
- "default": "./dist/zklogin/index.mjs"
115
- },
116
- "./graphql/schema": {
117
- "types": "./dist/graphql/schema/index.d.mts",
118
- "import": "./dist/graphql/schema/index.mjs",
119
- "default": "./dist/graphql/schema/index.mjs"
120
- }
121
- },
122
- "repository": {
123
- "type": "git",
124
- "url": "git+https://github.com/GeunhwaJeong/ts-sdks.git"
125
- },
126
- "bugs": {
127
- "url": "https://github.com/GeunhwaJeong/ts-sdks/issues/new"
128
- },
129
- "publishConfig": {
130
- "access": "public"
131
- },
132
- "devDependencies": {
133
- "@0no-co/graphqlsp": "^1.15.2",
134
- "@graphql-codegen/add": "^6.0.0",
135
- "@graphql-codegen/cli": "^6.1.1",
136
- "@graphql-codegen/typed-document-node": "^6.1.5",
137
- "@graphql-codegen/typescript": "5.0.7",
138
- "@graphql-codegen/typescript-document-nodes": "5.0.7",
139
- "@graphql-codegen/typescript-operations": "^5.0.7",
140
- "@iarna/toml": "^2.2.5",
141
- "@parcel/watcher": "^2.5.4",
142
- "@types/node": "^25.0.8",
143
- "@types/tmp": "^0.2.6",
144
- "@types/ws": "^8.18.1",
145
- "cross-env": "^10.1.0",
146
- "graphql-config": "^5.1.5",
147
- "msw": "^2.12.7",
148
- "tmp": "^0.2.5",
149
- "ts-retry-promise": "^0.8.1",
150
- "typescript": "^5.9.3",
151
- "vite": "^7.3.1",
152
- "vite-tsconfig-paths": "^6.0.4",
153
- "vitest": "^4.0.17",
154
- "wait-on": "^9.0.3",
155
- "ws": "^8.19.0"
156
- },
157
- "dependencies": {
158
- "@graphql-typed-document-node/core": "^3.2.0",
159
- "@noble/curves": "^2.0.1",
160
- "@noble/hashes": "^2.0.1",
161
- "@protobuf-ts/grpcweb-transport": "^2.11.1",
162
- "@protobuf-ts/runtime": "^2.11.1",
163
- "@protobuf-ts/runtime-rpc": "^2.11.1",
164
- "@scure/base": "^2.0.0",
165
- "@scure/bip32": "^2.0.1",
166
- "@scure/bip39": "^2.0.1",
167
- "gql.tada": "^1.9.0",
168
- "graphql": "^16.12.0",
169
- "poseidon-lite": "0.2.1",
170
- "valibot": "^1.2.0",
171
- "@haneullabs/utils": "^0.3.1",
172
- "@haneullabs/bcs": "^2.0.2"
173
- },
174
- "scripts": {
175
- "clean": "rm -rf tsconfig.tsbuildinfo ./dist",
176
- "codegen": "pnpm codegen:graphql && pnpm codegen:grpc && pnpm lint:fix",
177
- "codegen:graphql": "graphql-codegen --config graphql-codegen.ts",
178
- "codegen:version": "node genversion.mjs",
179
- "codegen:grpc": "rm -rf src/grpc/proto && mkdir src/grpc/proto && pnpm codegen:grpc-protoc && pnpm codegen:grpc-header && pnpm codegen:grpc-extensions && pnpm codegen:grpc-types",
180
- "codegen:grpc-types": "tsx scripts/generate-grpc-types.ts",
181
- "codegen:grpc-protoc": "protoc --ts_out ./src/grpc/proto --ts_opt force_server_none --ts_opt optimize_code_size --ts_opt ts_nocheck -I ../../../haneul-apis/proto -I ../../../haneul-apis/proto ../../../haneul-apis/proto/haneul/rpc/v2/*.proto ../../../haneul-apis/proto/google/*/*.proto",
182
- "codegen:grpc-header": "find src/grpc/proto -type f -exec sh -c 'echo \"// Copyright (c) Haneul Labs, Inc.\\n// SPDX-License-Identifier: Apache-2.0\\n\" | cat - {} > temp && mv temp {}' \\;",
183
- "codegen:grpc-extensions": "find src/grpc/proto -name '*.ts' | xargs sed -i '' -E 's/from \"(\\.[^\"]+)\"/from \"\\1.js\"/g'",
184
- "build": "rm -rf dist && node genversion.mjs && tsc --noEmit && tsdown",
185
- "vitest": "vitest",
186
- "test": "pnpm test:typecheck && pnpm test:unit",
187
- "test:typecheck": "tsc -p ./test",
188
- "test:unit": "vitest run unit __tests__",
189
- "test:e2e": "vitest run --config test/e2e/vitest.config.mts",
190
- "size": "size-limit",
191
- "analyze": "size-limit --why",
192
- "prettier:check": "prettier -c --ignore-unknown .",
193
- "prettier:fix": "prettier -w --ignore-unknown .",
194
- "oxlint:check": "oxlint .",
195
- "oxlint:fix": "oxlint --fix",
196
- "lint": "pnpm run oxlint:check && pnpm run prettier:check",
197
- "lint:fix": "pnpm run oxlint:fix && pnpm run prettier:fix",
198
- "update-graphql-schema": "pnpm tsx scripts/update-graphql-schema.ts"
199
- }
200
- }
2
+ "name": "@haneullabs/haneul",
3
+ "author": "Haneul Labs <build@haneul-labs.com>",
4
+ "description": "Haneul TypeScript API",
5
+ "homepage": "https://sdk.haneul-labs.com",
6
+ "version": "2.5.0",
7
+ "license": "Apache-2.0",
8
+ "sideEffects": false,
9
+ "files": [
10
+ "CHANGELOG.md",
11
+ "LICENSE",
12
+ "README.md",
13
+ "bcs",
14
+ "builder",
15
+ "client",
16
+ "cryptography",
17
+ "dist",
18
+ "experimental",
19
+ "faucet",
20
+ "graphql",
21
+ "grpc",
22
+ "jsonRpc",
23
+ "keypairs",
24
+ "multisig",
25
+ "src",
26
+ "transactions",
27
+ "utils",
28
+ "verify",
29
+ "zklogin"
30
+ ],
31
+ "engines": {
32
+ "node": ">=22"
33
+ },
34
+ "type": "module",
35
+ "exports": {
36
+ "./bcs": {
37
+ "types": "./dist/bcs/index.d.mts",
38
+ "import": "./dist/bcs/index.mjs",
39
+ "default": "./dist/bcs/index.mjs"
40
+ },
41
+ "./client": {
42
+ "types": "./dist/client/index.d.mts",
43
+ "import": "./dist/client/index.mjs",
44
+ "default": "./dist/client/index.mjs"
45
+ },
46
+ "./cryptography": {
47
+ "types": "./dist/cryptography/index.d.mts",
48
+ "import": "./dist/cryptography/index.mjs",
49
+ "default": "./dist/cryptography/index.mjs"
50
+ },
51
+ "./faucet": {
52
+ "types": "./dist/faucet/index.d.mts",
53
+ "import": "./dist/faucet/index.mjs",
54
+ "default": "./dist/faucet/index.mjs"
55
+ },
56
+ "./graphql": {
57
+ "types": "./dist/graphql/index.d.mts",
58
+ "import": "./dist/graphql/index.mjs",
59
+ "default": "./dist/graphql/index.mjs"
60
+ },
61
+ "./grpc": {
62
+ "types": "./dist/grpc/index.d.mts",
63
+ "import": "./dist/grpc/index.mjs",
64
+ "default": "./dist/grpc/index.mjs"
65
+ },
66
+ "./jsonRpc": {
67
+ "types": "./dist/jsonRpc/index.d.mts",
68
+ "import": "./dist/jsonRpc/index.mjs",
69
+ "default": "./dist/jsonRpc/index.mjs"
70
+ },
71
+ "./keypairs/ed25519": {
72
+ "types": "./dist/keypairs/ed25519/index.d.mts",
73
+ "import": "./dist/keypairs/ed25519/index.mjs",
74
+ "default": "./dist/keypairs/ed25519/index.mjs"
75
+ },
76
+ "./keypairs/secp256k1": {
77
+ "types": "./dist/keypairs/secp256k1/index.d.mts",
78
+ "import": "./dist/keypairs/secp256k1/index.mjs",
79
+ "default": "./dist/keypairs/secp256k1/index.mjs"
80
+ },
81
+ "./keypairs/secp256r1": {
82
+ "types": "./dist/keypairs/secp256r1/index.d.mts",
83
+ "import": "./dist/keypairs/secp256r1/index.mjs",
84
+ "default": "./dist/keypairs/secp256r1/index.mjs"
85
+ },
86
+ "./keypairs/passkey": {
87
+ "types": "./dist/keypairs/passkey/index.d.mts",
88
+ "import": "./dist/keypairs/passkey/index.mjs",
89
+ "default": "./dist/keypairs/passkey/index.mjs"
90
+ },
91
+ "./multisig": {
92
+ "types": "./dist/multisig/index.d.mts",
93
+ "import": "./dist/multisig/index.mjs",
94
+ "default": "./dist/multisig/index.mjs"
95
+ },
96
+ "./transactions": {
97
+ "types": "./dist/transactions/index.d.mts",
98
+ "import": "./dist/transactions/index.mjs",
99
+ "default": "./dist/transactions/index.mjs"
100
+ },
101
+ "./utils": {
102
+ "types": "./dist/utils/index.d.mts",
103
+ "import": "./dist/utils/index.mjs",
104
+ "default": "./dist/utils/index.mjs"
105
+ },
106
+ "./verify": {
107
+ "types": "./dist/verify/index.d.mts",
108
+ "import": "./dist/verify/index.mjs",
109
+ "default": "./dist/verify/index.mjs"
110
+ },
111
+ "./zklogin": {
112
+ "types": "./dist/zklogin/index.d.mts",
113
+ "import": "./dist/zklogin/index.mjs",
114
+ "default": "./dist/zklogin/index.mjs"
115
+ },
116
+ "./graphql/schema": {
117
+ "types": "./dist/graphql/schema/index.d.mts",
118
+ "import": "./dist/graphql/schema/index.mjs",
119
+ "default": "./dist/graphql/schema/index.mjs"
120
+ }
121
+ },
122
+ "scripts": {
123
+ "clean": "rm -rf tsconfig.tsbuildinfo ./dist",
124
+ "codegen": "pnpm codegen:graphql && pnpm codegen:grpc && pnpm lint:fix",
125
+ "codegen:graphql": "graphql-codegen --config graphql-codegen.ts",
126
+ "codegen:version": "node genversion.mjs",
127
+ "codegen:grpc": "rm -rf src/grpc/proto && mkdir src/grpc/proto && pnpm codegen:grpc-protoc && pnpm codegen:grpc-header && pnpm codegen:grpc-extensions && pnpm codegen:grpc-types",
128
+ "codegen:grpc-types": "tsx scripts/generate-grpc-types.ts",
129
+ "codegen:grpc-protoc": "protoc --ts_out ./src/grpc/proto --ts_opt force_server_none --ts_opt optimize_code_size --ts_opt ts_nocheck -I ../../../haneul-apis/proto -I ../../../haneul-apis/proto ../../../haneul-apis/proto/haneul/rpc/v2/*.proto ../../../haneul-apis/proto/google/*/*.proto",
130
+ "codegen:grpc-header": "find src/grpc/proto -type f -exec sh -c 'echo \"// Copyright (c) Haneul Labs, Inc.\\n// SPDX-License-Identifier: Apache-2.0\\n\" | cat - {} > temp && mv temp {}' \\;",
131
+ "codegen:grpc-extensions": "find src/grpc/proto -name '*.ts' | xargs sed -i '' -E 's/from \"(\\.[^\"]+)\"/from \"\\1.js\"/g'",
132
+ "build": "rm -rf dist && node genversion.mjs && tsc --noEmit && tsdown",
133
+ "vitest": "vitest",
134
+ "test": "pnpm test:typecheck && pnpm test:unit",
135
+ "test:typecheck": "tsc -p ./test",
136
+ "test:unit": "vitest run unit __tests__",
137
+ "test:e2e": "vitest run --config test/e2e/vitest.config.mts",
138
+ "size": "size-limit",
139
+ "analyze": "size-limit --why",
140
+ "prettier:check": "prettier -c --ignore-unknown .",
141
+ "prettier:fix": "prettier -w --ignore-unknown .",
142
+ "oxlint:check": "oxlint .",
143
+ "oxlint:fix": "oxlint --fix",
144
+ "lint": "pnpm run oxlint:check && pnpm run prettier:check",
145
+ "lint:fix": "pnpm run oxlint:fix && pnpm run prettier:fix",
146
+ "update-graphql-schema": "pnpm tsx scripts/update-graphql-schema.ts"
147
+ },
148
+ "repository": {
149
+ "type": "git",
150
+ "url": "git+https://github.com/GeunhwaJeong/ts-sdks.git"
151
+ },
152
+ "bugs": {
153
+ "url": "https://github.com/GeunhwaJeong/ts-sdks/issues/new"
154
+ },
155
+ "publishConfig": {
156
+ "access": "public"
157
+ },
158
+ "devDependencies": {
159
+ "@0no-co/graphqlsp": "^1.15.2",
160
+ "@graphql-codegen/add": "^6.0.0",
161
+ "@graphql-codegen/cli": "^6.1.1",
162
+ "@graphql-codegen/typed-document-node": "^6.1.5",
163
+ "@graphql-codegen/typescript": "5.0.7",
164
+ "@graphql-codegen/typescript-document-nodes": "5.0.7",
165
+ "@graphql-codegen/typescript-operations": "^5.0.7",
166
+ "@iarna/toml": "^2.2.5",
167
+ "@parcel/watcher": "^2.5.4",
168
+ "@types/node": "^25.0.8",
169
+ "@types/tmp": "^0.2.6",
170
+ "@types/ws": "^8.18.1",
171
+ "cross-env": "^10.1.0",
172
+ "graphql-config": "^5.1.5",
173
+ "msw": "^2.12.7",
174
+ "tmp": "^0.2.5",
175
+ "ts-retry-promise": "^0.8.1",
176
+ "typescript": "^5.9.3",
177
+ "vite": "^7.3.1",
178
+ "vite-tsconfig-paths": "^6.0.4",
179
+ "vitest": "^4.0.17",
180
+ "wait-on": "^9.0.3",
181
+ "ws": "^8.19.0"
182
+ },
183
+ "dependencies": {
184
+ "@graphql-typed-document-node/core": "^3.2.0",
185
+ "@haneullabs/bcs": "workspace:^",
186
+ "@haneullabs/utils": "workspace:^",
187
+ "@noble/curves": "^2.0.1",
188
+ "@noble/hashes": "^2.0.1",
189
+ "@protobuf-ts/grpcweb-transport": "^2.11.1",
190
+ "@protobuf-ts/runtime": "^2.11.1",
191
+ "@protobuf-ts/runtime-rpc": "^2.11.1",
192
+ "@scure/base": "^2.0.0",
193
+ "@scure/bip32": "^2.0.1",
194
+ "@scure/bip39": "^2.0.1",
195
+ "gql.tada": "^1.9.0",
196
+ "graphql": "^16.12.0",
197
+ "poseidon-lite": "0.2.1",
198
+ "valibot": "^1.2.0"
199
+ }
200
+ }
package/src/bcs/bcs.ts CHANGED
@@ -360,7 +360,7 @@ export const PasskeyAuthenticator = bcs.struct('PasskeyAuthenticator', {
360
360
  export const MoveObjectType = bcs.enum('MoveObjectType', {
361
361
  Other: StructTag,
362
362
  GasCoin: null,
363
- StakedSui: null,
363
+ StakedHaneul: null,
364
364
  Coin: TypeTag,
365
365
  AccumulatorBalanceWrapper: null,
366
366
  });
@@ -3,7 +3,7 @@
3
3
 
4
4
  import { parse } from 'valibot';
5
5
 
6
- import { normalizeHaneulAddress, normalizeSuiObjectId, HANEUL_TYPE_ARG } from '../utils/index.js';
6
+ import { normalizeHaneulAddress, normalizeHaneulObjectId, HANEUL_TYPE_ARG } from '../utils/index.js';
7
7
  import type { ClientWithCoreApi } from './core.js';
8
8
  import { ObjectRefSchema } from '../transactions/data/internal.js';
9
9
  import type { CallArg, Command } from '../transactions/data/internal.js';
@@ -227,7 +227,7 @@ async function resolveObjectReferences(
227
227
 
228
228
  const dedupedIds = [
229
229
  ...new Set(
230
- objectsToResolve.map((input) => normalizeSuiObjectId(input.UnresolvedObject.objectId)),
230
+ objectsToResolve.map((input) => normalizeHaneulObjectId(input.UnresolvedObject.objectId)),
231
231
  ),
232
232
  ];
233
233