@scallop-io/sui-kit
Advanced tools
Comparing version 0.44.2 to 0.45.0
@@ -100,2 +100,3 @@ "use strict"; | ||
// src/libs/suiAccountManager/index.ts | ||
var import_cryptography = require("@mysten/sui.js/cryptography"); | ||
var SuiAccountManager = class { | ||
@@ -109,3 +110,3 @@ /** | ||
* @param mnemonics, 12 or 24 mnemonics words, separated by space | ||
* @param secretKey, base64 or hex string, when mnemonics is provided, secretKey will be ignored | ||
* @param secretKey, base64 or hex string or Bech32 string, when mnemonics is provided, secretKey will be ignored | ||
*/ | ||
@@ -118,8 +119,20 @@ constructor({ mnemonics, secretKey } = {}) { | ||
} | ||
this.currentKeyPair = this.secretKey ? import_ed255192.Ed25519Keypair.fromSecretKey( | ||
normalizePrivateKey(hexOrBase64ToUint8Array(this.secretKey)) | ||
) : getKeyPair(this.mnemonics); | ||
this.currentKeyPair = this.secretKey ? this.parseSecretKey(this.secretKey) : getKeyPair(this.mnemonics); | ||
this.currentAddress = this.currentKeyPair.getPublicKey().toSuiAddress(); | ||
} | ||
/** | ||
* Check if the secretKey starts with bench32 format | ||
*/ | ||
parseSecretKey(secretKey) { | ||
if (secretKey.startsWith(import_cryptography.SUI_PRIVATE_KEY_PREFIX)) { | ||
const { secretKey: uint8ArraySecretKey } = (0, import_cryptography.decodeSuiPrivateKey)(secretKey); | ||
return import_ed255192.Ed25519Keypair.fromSecretKey( | ||
normalizePrivateKey(uint8ArraySecretKey) | ||
); | ||
} | ||
return import_ed255192.Ed25519Keypair.fromSecretKey( | ||
normalizePrivateKey(hexOrBase64ToUint8Array(secretKey)) | ||
); | ||
} | ||
/** | ||
* if derivePathParams is not provided or mnemonics is empty, it will return the currentKeyPair. | ||
@@ -705,3 +718,3 @@ * else: | ||
* @param mnemonics, 12 or 24 mnemonics words, separated by space | ||
* @param secretKey, base64 or hex string, when mnemonics is provided, secretKey will be ignored | ||
* @param secretKey, base64 or hex string or bech32, when mnemonics is provided, secretKey will be ignored | ||
* @param networkType, 'testnet' | 'mainnet' | 'devnet' | 'localnet', default is 'mainnet' | ||
@@ -708,0 +721,0 @@ * @param fullnodeUrl, the fullnode url, default is the preconfig fullnode url for the given network type |
@@ -100,2 +100,3 @@ "use strict"; | ||
// src/libs/suiAccountManager/index.ts | ||
var import_cryptography = require("@mysten/sui.js/cryptography"); | ||
var SuiAccountManager = class { | ||
@@ -109,3 +110,3 @@ /** | ||
* @param mnemonics, 12 or 24 mnemonics words, separated by space | ||
* @param secretKey, base64 or hex string, when mnemonics is provided, secretKey will be ignored | ||
* @param secretKey, base64 or hex string or Bech32 string, when mnemonics is provided, secretKey will be ignored | ||
*/ | ||
@@ -118,8 +119,20 @@ constructor({ mnemonics, secretKey } = {}) { | ||
} | ||
this.currentKeyPair = this.secretKey ? import_ed255192.Ed25519Keypair.fromSecretKey( | ||
normalizePrivateKey(hexOrBase64ToUint8Array(this.secretKey)) | ||
) : getKeyPair(this.mnemonics); | ||
this.currentKeyPair = this.secretKey ? this.parseSecretKey(this.secretKey) : getKeyPair(this.mnemonics); | ||
this.currentAddress = this.currentKeyPair.getPublicKey().toSuiAddress(); | ||
} | ||
/** | ||
* Check if the secretKey starts with bench32 format | ||
*/ | ||
parseSecretKey(secretKey) { | ||
if (secretKey.startsWith(import_cryptography.SUI_PRIVATE_KEY_PREFIX)) { | ||
const { secretKey: uint8ArraySecretKey } = (0, import_cryptography.decodeSuiPrivateKey)(secretKey); | ||
return import_ed255192.Ed25519Keypair.fromSecretKey( | ||
normalizePrivateKey(uint8ArraySecretKey) | ||
); | ||
} | ||
return import_ed255192.Ed25519Keypair.fromSecretKey( | ||
normalizePrivateKey(hexOrBase64ToUint8Array(secretKey)) | ||
); | ||
} | ||
/** | ||
* if derivePathParams is not provided or mnemonics is empty, it will return the currentKeyPair. | ||
@@ -705,3 +718,3 @@ * else: | ||
* @param mnemonics, 12 or 24 mnemonics words, separated by space | ||
* @param secretKey, base64 or hex string, when mnemonics is provided, secretKey will be ignored | ||
* @param secretKey, base64 or hex string or bech32, when mnemonics is provided, secretKey will be ignored | ||
* @param networkType, 'testnet' | 'mainnet' | 'devnet' | 'localnet', default is 'mainnet' | ||
@@ -708,0 +721,0 @@ * @param fullnodeUrl, the fullnode url, default is the preconfig fullnode url for the given network type |
@@ -15,6 +15,10 @@ import { Ed25519Keypair } from '@mysten/sui.js/keypairs/ed25519'; | ||
* @param mnemonics, 12 or 24 mnemonics words, separated by space | ||
* @param secretKey, base64 or hex string, when mnemonics is provided, secretKey will be ignored | ||
* @param secretKey, base64 or hex string or Bech32 string, when mnemonics is provided, secretKey will be ignored | ||
*/ | ||
constructor({ mnemonics, secretKey }?: AccountMangerParams); | ||
/** | ||
* Check if the secretKey starts with bench32 format | ||
*/ | ||
parseSecretKey(secretKey: string): Ed25519Keypair; | ||
/** | ||
* if derivePathParams is not provided or mnemonics is empty, it will return the currentKeyPair. | ||
@@ -21,0 +25,0 @@ * else: |
@@ -16,12 +16,11 @@ import { TransactionBlock } from '@mysten/sui.js/transactions'; | ||
kind: "Input"; | ||
value?: any; | ||
type?: "object" | undefined; | ||
value?: any; | ||
} | { | ||
type: "pure"; | ||
index: number; | ||
kind: "Input"; | ||
type: "pure"; | ||
value?: any; | ||
})[]; | ||
transactions: ({ | ||
typeArguments: string[]; | ||
kind: "MoveCall"; | ||
@@ -31,8 +30,8 @@ arguments: ({ | ||
kind: "Input"; | ||
value?: any; | ||
type?: "object" | undefined; | ||
value?: any; | ||
} | { | ||
type: "pure"; | ||
index: number; | ||
kind: "Input"; | ||
type: "pure"; | ||
value?: any; | ||
@@ -50,2 +49,3 @@ } | { | ||
target: `${string}::${string}::${string}`; | ||
typeArguments: string[]; | ||
} | { | ||
@@ -55,8 +55,8 @@ address: { | ||
kind: "Input"; | ||
value?: any; | ||
type?: "object" | undefined; | ||
value?: any; | ||
} | { | ||
type: "pure"; | ||
index: number; | ||
kind: "Input"; | ||
type: "pure"; | ||
value?: any; | ||
@@ -77,8 +77,8 @@ } | { | ||
kind: "Input"; | ||
value?: any; | ||
type?: "object" | undefined; | ||
value?: any; | ||
} | { | ||
type: "pure"; | ||
index: number; | ||
kind: "Input"; | ||
type: "pure"; | ||
value?: any; | ||
@@ -100,8 +100,8 @@ } | { | ||
kind: "Input"; | ||
value?: any; | ||
type?: "object" | undefined; | ||
value?: any; | ||
} | { | ||
type: "pure"; | ||
index: number; | ||
kind: "Input"; | ||
type: "pure"; | ||
value?: any; | ||
@@ -121,8 +121,8 @@ } | { | ||
kind: "Input"; | ||
value?: any; | ||
type?: "object" | undefined; | ||
value?: any; | ||
} | { | ||
type: "pure"; | ||
index: number; | ||
kind: "Input"; | ||
type: "pure"; | ||
value?: any; | ||
@@ -144,8 +144,8 @@ } | { | ||
kind: "Input"; | ||
value?: any; | ||
type?: "object" | undefined; | ||
value?: any; | ||
} | { | ||
type: "pure"; | ||
index: number; | ||
kind: "Input"; | ||
type: "pure"; | ||
value?: any; | ||
@@ -165,8 +165,8 @@ } | { | ||
kind: "Input"; | ||
value?: any; | ||
type?: "object" | undefined; | ||
value?: any; | ||
} | { | ||
type: "pure"; | ||
index: number; | ||
kind: "Input"; | ||
type: "pure"; | ||
value?: any; | ||
@@ -184,17 +184,19 @@ } | { | ||
} | { | ||
type: { | ||
Some: import("@mysten/sui.js/bcs").TypeTag; | ||
} | { | ||
None: true | null; | ||
}; | ||
kind: "MakeMoveVec"; | ||
objects: ({ | ||
kind: "Publish"; | ||
modules: number[][]; | ||
dependencies: string[]; | ||
} | { | ||
kind: "Upgrade"; | ||
modules: number[][]; | ||
dependencies: string[]; | ||
packageId: string; | ||
ticket: { | ||
index: number; | ||
kind: "Input"; | ||
value?: any; | ||
type?: "object" | undefined; | ||
value?: any; | ||
} | { | ||
type: "pure"; | ||
index: number; | ||
kind: "Input"; | ||
type: "pure"; | ||
value?: any; | ||
@@ -210,21 +212,19 @@ } | { | ||
kind: "NestedResult"; | ||
})[]; | ||
}; | ||
} | { | ||
kind: "Publish"; | ||
modules: number[][]; | ||
dependencies: string[]; | ||
} | { | ||
kind: "Upgrade"; | ||
modules: number[][]; | ||
dependencies: string[]; | ||
packageId: string; | ||
ticket: { | ||
kind: "MakeMoveVec"; | ||
type: { | ||
Some: import("@mysten/sui.js/bcs").TypeTag; | ||
} | { | ||
None: true | null; | ||
}; | ||
objects: ({ | ||
index: number; | ||
kind: "Input"; | ||
value?: any; | ||
type?: "object" | undefined; | ||
value?: any; | ||
} | { | ||
type: "pure"; | ||
index: number; | ||
kind: "Input"; | ||
type: "pure"; | ||
value?: any; | ||
@@ -240,6 +240,5 @@ } | { | ||
kind: "NestedResult"; | ||
}; | ||
})[]; | ||
})[]; | ||
gasConfig: { | ||
owner?: string | undefined; | ||
payment?: { | ||
@@ -250,2 +249,3 @@ digest: string; | ||
}[] | undefined; | ||
owner?: string | undefined; | ||
price?: string | number | bigint | undefined; | ||
@@ -264,8 +264,8 @@ budget?: string | number | bigint | undefined; | ||
kind: "Input"; | ||
value?: any; | ||
type?: "object" | undefined; | ||
value?: any; | ||
} | { | ||
type: "pure"; | ||
index: number; | ||
kind: "Input"; | ||
type: "pure"; | ||
value?: any; | ||
@@ -276,28 +276,13 @@ }; | ||
kind: "Input"; | ||
value?: any; | ||
type?: "object" | undefined; | ||
value?: any; | ||
} | { | ||
type: "pure"; | ||
index: number; | ||
kind: "Input"; | ||
type: "pure"; | ||
value?: any; | ||
}; | ||
object(value: string | ObjectCallArg): { | ||
index: number; | ||
kind: "Input"; | ||
type?: "object" | undefined; | ||
value?: any; | ||
}; | ||
objectRef(ref: SuiObjectRef): { | ||
index: number; | ||
kind: "Input"; | ||
type?: "object" | undefined; | ||
value?: any; | ||
}; | ||
sharedObjectRef(ref: SharedObjectRef): { | ||
index: number; | ||
kind: "Input"; | ||
type?: "object" | undefined; | ||
value?: any; | ||
}; | ||
object(value: string | ObjectCallArg): TransactionObjectArgument; | ||
objectRef(ref: SuiObjectRef): TransactionObjectArgument; | ||
sharedObjectRef(ref: SharedObjectRef): TransactionObjectArgument; | ||
setSender(sender: string): void; | ||
@@ -304,0 +289,0 @@ setSenderIfNotSet(sender: string): void; |
@@ -33,5 +33,5 @@ import type { TransactionArgument, TransactionBlock, TransactionObjectArgument } from '@mysten/sui.js/transactions'; | ||
export declare function convertArgs(txBlock: TransactionBlock, args: (SuiTxArg | SuiVecTxArg)[]): ({ | ||
type: "pure"; | ||
index: number; | ||
kind: "Input"; | ||
type: "pure"; | ||
value?: any; | ||
@@ -47,5 +47,5 @@ } | TransactionObjectArgument | import("@mysten/bcs").SerializedBcs<unknown, unknown>)[]; | ||
export declare function convertAddressArg(txBlock: TransactionBlock, arg: SuiAddressArg): TransactionObjectArgument | { | ||
type: "pure"; | ||
index: number; | ||
kind: "Input"; | ||
type: "pure"; | ||
value?: any; | ||
@@ -52,0 +52,0 @@ } | import("@mysten/bcs").SerializedBcs<unknown, unknown>; |
@@ -22,3 +22,3 @@ import { TransactionBlock } from '@mysten/sui.js/transactions'; | ||
* @param mnemonics, 12 or 24 mnemonics words, separated by space | ||
* @param secretKey, base64 or hex string, when mnemonics is provided, secretKey will be ignored | ||
* @param secretKey, base64 or hex string or bech32, when mnemonics is provided, secretKey will be ignored | ||
* @param networkType, 'testnet' | 'mainnet' | 'devnet' | 'localnet', default is 'mainnet' | ||
@@ -25,0 +25,0 @@ * @param fullnodeUrl, the fullnode url, default is the preconfig fullnode url for the given network type |
{ | ||
"name": "@scallop-io/sui-kit", | ||
"version": "0.44.2", | ||
"version": "0.45.0", | ||
"description": "Tookit for interacting with SUI network", | ||
@@ -41,3 +41,3 @@ "keywords": [ | ||
"@mysten/bcs": "^0.8.1", | ||
"@mysten/sui.js": "^0.44.0", | ||
"@mysten/sui.js": "^0.52.0", | ||
"@noble/curves": "^1.2.0", | ||
@@ -47,2 +47,3 @@ "@noble/hashes": "^1.3.2", | ||
"assert": "^2.1.0", | ||
"bech32": "^2.0.0", | ||
"superstruct": "^1.0.3", | ||
@@ -53,3 +54,3 @@ "ts-retry-promise": "^0.7.1", | ||
"peerDependencies": { | ||
"@mysten/sui.js": "^0.44.0" | ||
"@mysten/sui.js": "^0.52.0" | ||
}, | ||
@@ -56,0 +57,0 @@ "devDependencies": { |
@@ -6,2 +6,6 @@ import { Ed25519Keypair } from '@mysten/sui.js/keypairs/ed25519'; | ||
import type { AccountMangerParams, DerivePathParams } from 'src/types'; | ||
import { | ||
SUI_PRIVATE_KEY_PREFIX, | ||
decodeSuiPrivateKey, | ||
} from '@mysten/sui.js/cryptography'; | ||
@@ -21,3 +25,3 @@ export class SuiAccountManager { | ||
* @param mnemonics, 12 or 24 mnemonics words, separated by space | ||
* @param secretKey, base64 or hex string, when mnemonics is provided, secretKey will be ignored | ||
* @param secretKey, base64 or hex string or Bech32 string, when mnemonics is provided, secretKey will be ignored | ||
*/ | ||
@@ -35,5 +39,3 @@ constructor({ mnemonics, secretKey }: AccountMangerParams = {}) { | ||
this.currentKeyPair = this.secretKey | ||
? Ed25519Keypair.fromSecretKey( | ||
normalizePrivateKey(hexOrBase64ToUint8Array(this.secretKey)) | ||
) | ||
? this.parseSecretKey(this.secretKey) | ||
: getKeyPair(this.mnemonics); | ||
@@ -44,2 +46,18 @@ this.currentAddress = this.currentKeyPair.getPublicKey().toSuiAddress(); | ||
/** | ||
* Check if the secretKey starts with bench32 format | ||
*/ | ||
parseSecretKey(secretKey: string) { | ||
if (secretKey.startsWith(SUI_PRIVATE_KEY_PREFIX)) { | ||
const { secretKey: uint8ArraySecretKey } = decodeSuiPrivateKey(secretKey); | ||
return Ed25519Keypair.fromSecretKey( | ||
normalizePrivateKey(uint8ArraySecretKey) | ||
); | ||
} | ||
return Ed25519Keypair.fromSecretKey( | ||
normalizePrivateKey(hexOrBase64ToUint8Array(secretKey)) | ||
); | ||
} | ||
/** | ||
* if derivePathParams is not provided or mnemonics is empty, it will return the currentKeyPair. | ||
@@ -46,0 +64,0 @@ * else: |
@@ -38,3 +38,3 @@ /** | ||
* @param mnemonics, 12 or 24 mnemonics words, separated by space | ||
* @param secretKey, base64 or hex string, when mnemonics is provided, secretKey will be ignored | ||
* @param secretKey, base64 or hex string or bech32, when mnemonics is provided, secretKey will be ignored | ||
* @param networkType, 'testnet' | 'mainnet' | 'devnet' | 'localnet', default is 'mainnet' | ||
@@ -41,0 +41,0 @@ * @param fullnodeUrl, the fullnode url, default is the preconfig fullnode url for the given network type |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
313613
4814
11
+ Addedbech32@^2.0.0
+ Added@0no-co/graphql.web@1.1.1(transitive)
+ Added@0no-co/graphqlsp@1.12.16(transitive)
+ Added@gql.tada/cli-utils@1.6.3(transitive)
+ Added@gql.tada/internal@1.0.8(transitive)
+ Added@graphql-typed-document-node/core@3.2.0(transitive)
+ Added@mysten/bcs@0.11.1(transitive)
+ Added@mysten/sui.js@0.52.0(transitive)
+ Addedbech32@2.0.0(transitive)
+ Addedgql.tada@1.8.10(transitive)
+ Addedgraphql@16.10.0(transitive)
+ Addedtypescript@5.7.3(transitive)
- Removed@mysten/sui.js@0.44.0(transitive)
- Removed@open-rpc/client-js@1.8.1(transitive)
- Removedevents@3.3.0(transitive)
- Removedisomorphic-fetch@3.0.0(transitive)
- Removedisomorphic-ws@5.0.0(transitive)
- Removednode-fetch@2.7.0(transitive)
- Removedstrict-event-emitter-types@2.0.0(transitive)
- Removedtr46@0.0.3(transitive)
- Removedwebidl-conversions@3.0.1(transitive)
- Removedwhatwg-fetch@3.6.20(transitive)
- Removedwhatwg-url@5.0.0(transitive)
- Removedws@7.5.10(transitive)
Updated@mysten/sui.js@^0.52.0