@layerzerolabs/lz-core 3.0.66 → 3.0.68-ton.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +44 -7
- package/dist/index.d.ts +44 -7
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/transaction.ts","../src/signer.ts"],"names":[],"mappings":";;;AAmBa,IAAA,KAAA,GAAN,MAAM,MAAM,CAAA;AAAA,EAEP,YAAmB,KAAgB,EAAA;AAAhB,IAAA,IAAA,CAAA,KAAA,GAAA,KAAA;AAD3B,IAAA,IAAA,CAAS,IAAO,GAAA,OAAA;AAAA;AAC4B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQ5C,OAAO,KAAQ,GAA2B,EAAA;AACtC,IAAO,OAAA,IAAI,OAAM,GAAG,CAAA;AAAA;AAE5B;AAKa,IAAA,qBAAA,GAAN,MAAM,sBAAsB,CAAA;AAAA,EAEvB,YAAmB,KAAgB,EAAA;AAAhB,IAAA,IAAA,CAAA,KAAA,GAAA,KAAA;AAD3B,IAAA,IAAA,CAAS,IAAO,GAAA,uBAAA;AAAA;AAC4B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQ5C,OAAO,KAAQ,GAA2C,EAAA;AACtD,IAAO,OAAA,IAAI,uBAAsB,GAAG,CAAA;AAAA;AAE5C;AAyBa,IAAA,kBAAA,GAAN,MAAM,mBAAmB,CAAA;AAAA,EAEpB,YAAmB,OAAkB,EAAA;AAAlB,IAAA,IAAA,CAAA,OAAA,GAAA,OAAA;AAD3B,IAAA,IAAA,CAAS,IAAO,GAAA,oBAAA;AAAA;AAC8B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQ9C,OAAO,KAAQ,GAAm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,GAAmE,EAAA;AAC9E,IAAO,OAAA,IAAI,oBAAmB,GAAG,CAAA;AAAA;AAEzC;;;ACzEO,SAAS,cAAiB,GAAqC,EAAA;AAClE,EAAA,IAAI,OAAO,GAAA,KAAQ,QAAY,IAAA,GAAA,KAAQ,MAAa,OAAA,KAAA;AACpD,EAAA,MAAM,KAAM,GAA8B,CAAA,OAAA;AAC1C,EAAO,OAAA,OAAO,OAAO,UAAc,IAAA,OAAO,GAAG,MAAW,KAAA,QAAA,IAAY,GAAG,MAAW,KAAA,CAAA;AACtF","file":"index.cjs","sourcesContent":["import { NonPromise } from './promise'\n\n/**\n * By declare a unique field `type` in each class, it ensure that the instance of one class can not\n * be assigned to a variable of another class. Furthermore, it also help to distinguish the type of\n * the instance at runtime.\n * By private the constructor, it ensure that the instance of the class can only be created by the\n * static method `from`, and which can enforce the type of the input parameter should not be a promise.\n * Finally, it will be helpful for the compiler to infer the type of the instance and avoid the mistake.\n */\n\n/**\n * TransactionHash represents a transaction hash.\n */\nexport type TransactionHash = string | number\n\n/**\n * Block represents a block.\n */\nexport class Block {\n readonly type = 'Block'\n private constructor(public block: unknown) {}\n\n /**\n * Creates an instance of Block from a non-promise value.\n *\n * @param {NonPromise<T>} raw - The raw value to create the Block from.\n * @returns {Block} The created Block instance.\n */\n static from<T>(raw: NonPromise<T>): Block {\n return new Block(raw)\n }\n}\n\n/**\n * BlockWithTransactions represents a block with transactions.\n */\nexport class BlockWithTransactions {\n readonly type = 'BlockWithTransactions'\n private constructor(public block: unknown) {}\n\n /**\n * Creates an instance of BlockWithTransactions from a non-promise value.\n *\n * @param {NonPromise<T>} raw - The raw value to create the BlockWithTransactions from.\n * @returns {BlockWithTransactions} The created BlockWithTransactions instance.\n */\n static from<T>(raw: NonPromise<T>): BlockWithTransactions {\n return new BlockWithTransactions(raw)\n }\n}\n\n/**\n * BlockTag represents a block tag.\n */\nexport type BlockTag = string | number\n\n/**\n * Finality represents the finality of a block.\n */\nexport type Finality = 'confirmed' | 'finalized'\n\n/**\n * A union type to represent all the possible types of a transaction.\n */\ntype TransactionTypes =\n | TransactionRequest\n | TransactionResponse\n | TransactionReceipt\n | SignedTransaction\n | TransactionPending\n\n/**\n * TransactionRequest represents the request of a transaction.\n */\nexport class TransactionRequest {\n readonly type = 'TransactionRequest'\n private constructor(public request: unknown) {}\n\n /**\n * Creates an instance of TransactionRequest from a non-promise value.\n *\n * @param {Exclude<NonPromise<T>, TransactionTypes>} raw - The raw value to create the TransactionRequest from.\n * @returns {TransactionRequest} The created TransactionRequest instance.\n */\n static from<T>(raw: Exclude<NonPromise<T>, TransactionTypes>): TransactionRequest {\n return new TransactionRequest(raw)\n }\n}\n\n/**\n * TransactionResponse represents the response of a transaction.\n */\nexport class TransactionResponse {\n readonly type = 'TransactionResponse'\n private constructor(public response: unknown) {}\n\n /**\n * Creates an instance of TransactionResponse from a non-promise value.\n *\n * @param {Exclude<NonPromise<T>, TransactionTypes>} raw - The raw value to create the TransactionResponse from.\n * @returns {TransactionResponse} The created TransactionResponse instance.\n */\n static from<T>(raw: Exclude<NonPromise<T>, TransactionTypes>): TransactionResponse {\n return new TransactionResponse(raw)\n }\n}\n\n/**\n * TransactionReceipt represents the receipt of a transaction.\n */\nexport class TransactionReceipt {\n readonly type = 'TransactionReceipt'\n private constructor(public receipt: unknown) {}\n\n /**\n * Creates an instance of TransactionReceipt from a non-promise value.\n *\n * @param {Exclude<NonPromise<T>, TransactionTypes>} raw - The raw value to create the TransactionReceipt from.\n * @returns {TransactionReceipt} The created TransactionReceipt instance.\n */\n static from<T>(raw: Exclude<NonPromise<T>, TransactionTypes>): TransactionReceipt {\n return new TransactionReceipt(raw)\n }\n}\n\n/**\n * SignedTransaction represents a signed transaction.\n */\nexport class SignedTransaction {\n readonly type = 'SignedTransaction'\n private constructor(public signed: unknown) {}\n\n /**\n * Creates an instance of SignedTransaction from a non-promise value.\n *\n * @param {Exclude<NonPromise<T>, TransactionTypes>} raw - The raw value to create the SignedTransaction from.\n * @returns {SignedTransaction} The created SignedTransaction instance.\n */\n static from<T>(raw: Exclude<NonPromise<T>, TransactionTypes>): SignedTransaction {\n return new SignedTransaction(raw)\n }\n}\n\n/**\n * TransactionPending represents a pending transaction.\n */\nexport class TransactionPending {\n readonly type = 'TransactionPending'\n private constructor(public pending: unknown) {}\n\n /**\n * Creates an instance of TransactionPending from a non-promise value.\n *\n * @param {Exclude<NonPromise<T>, TransactionTypes>} raw - The raw value to create the TransactionPending from.\n * @returns {TransactionPending} The created TransactionPending instance.\n */\n static from<T>(raw: Exclude<NonPromise<T>, TransactionTypes>): TransactionPending {\n return new TransactionPending(raw)\n }\n}\n","import { Provider } from './provider'\nimport { SignedTransaction, TransactionPending, TransactionReceipt, TransactionRequest } from './transaction'\n\n/**\n * Interface representing a signer.\n *\n */\nexport interface Signer {\n /**\n * Connect to a provider.\n *\n * @param {Provider} provider - The provider to connect to.\n * @returns {Signer} The connected signer.\n */\n connect(provider: Provider): Signer\n\n /**\n * Sign a transaction.\n *\n * @param {TransactionRequest} transaction - The transaction request to sign.\n * @returns {Promise<SignedTransaction>} A promise that resolves to the signed transaction.\n */\n signTransaction(transaction: TransactionRequest): Promise<SignedTransaction>\n\n /**\n * Send a transaction.\n *\n * @param {SignedTransaction} transaction - The signed transaction to send.\n * @param {unknown} [sendOptions] - Optional parameters for sending the transaction.\n * @returns {Promise<TransactionPending>} A promise that resolves to the pending transaction.\n */\n sendTransaction(transaction: SignedTransaction, sendOptions?: unknown): Promise<TransactionPending>\n\n /**\n * Send a transaction and wait for confirmation.\n *\n * @param {SignedTransaction} transaction - The signed transaction to send.\n * @param {unknown} [opts] - Optional parameters for sending and confirming the transaction.\n * @returns {Promise<TransactionReceipt>} A promise that resolves to the transaction receipt.\n */\n sendAndConfirm(transaction: SignedTransaction, opts?: unknown): Promise<TransactionReceipt>\n\n /**\n * Sign a buffer (e.g. a message hash).\n *\n * @param {Uint8Array} buffer - The buffer to sign.\n * @returns {Promise<Uint8Array>} A promise that resolves to the signed buffer.\n */\n signBuffer(buffer: Uint8Array): Promise<Uint8Array>\n\n /**\n * Get the address of the signer.\n * this function NEED to return a Promise because ethers.Signer.getAddress() return a Promise<string>\n *\n * @returns {Promise<string>} A promise that resolves to the address of the signer.\n */\n getAddress(): Promise<string>\n\n /**\n * Native signer object\n */\n native: unknown\n}\n\n/**\n * Interface representing a connectable object.\n *\n * @template T - The type of the connectable object.\n */\nexport interface Connectable<T> {\n /**\n * Connect to a provider.\n *\n * @template U - The type of the provider.\n * @param {U} provider - The provider to connect to.\n * @returns {T} The connected object.\n */\n connect<U>(provider: U): T\n}\n\n/**\n * Check if an object is connectable.\n *\n * @template T - The type of the connectable object.\n * @param {unknown} obj - The object to check.\n * @returns {obj is Connectable<T>} True if the object is connectable, false otherwise.\n */\nexport function isConnectable<T>(obj: unknown): obj is Connectable<T> {\n if (typeof obj !== 'object' || obj === null) return false\n const fn = (obj as { connect?: unknown }).connect\n return typeof fn === 'function' && typeof fn.length === 'number' && fn.length === 1\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/transaction.ts","../src/signer.ts"],"names":[],"mappings":";;;AAmBa,IAAA,KAAA,GAAN,MAAM,MAAM,CAAA;AAAA,EAEP,YAAmB,KAAgB,EAAA;AAAhB,IAAA,IAAA,CAAA,KAAA,GAAA,KAAA;AAD3B,IAAA,IAAA,CAAS,IAAO,GAAA,OAAA;AAAA;AAC4B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQ5C,OAAO,KAAQ,GAA2B,EAAA;AACtC,IAAO,OAAA,IAAI,OAAM,GAAG,CAAA;AAAA;AAE5B;AAKa,IAAA,qBAAA,GAAN,MAAM,sBAAsB,CAAA;AAAA,EAEvB,YAAmB,KAAgB,EAAA;AAAhB,IAAA,IAAA,CAAA,KAAA,GAAA,KAAA;AAD3B,IAAA,IAAA,CAAS,IAAO,GAAA,uBAAA;AAAA;AAC4B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQ5C,OAAO,KAAQ,GAA2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Q,GAAkE,EAAA;AAC7E,IAAO,OAAA,IAAI,mBAAkB,GAAG,CAAA;AAAA;AAExC;AAKa,IAAA,kBAAA,GAAN,MAAM,mBAAmB,CAAA;AAAA,EAEpB,YAAmB,OAAkB,EAAA;AAAlB,IAAA,IAAA,CAAA,OAAA,GAAA,OAAA;AAD3B,IAAA,IAAA,CAAS,IAAO,GAAA,oBAAA;AAAA;AAC8B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQ9C,OAAO,KAAQ,GAAmE,EAAA;AAC9E,IAAO,OAAA,IAAI,oBAAmB,GAAG,CAAA;AAAA;AAEzC;;;ACzEO,SAAS,cAAiB,GAAqC,EAAA;AAClE,EAAA,IAAI,OAAO,GAAA,KAAQ,QAAY,IAAA,GAAA,KAAQ,MAAa,OAAA,KAAA;AACpD,EAAA,MAAM,KAAM,GAA8B,CAAA,OAAA;AAC1C,EAAO,OAAA,OAAO,OAAO,UAAc,IAAA,OAAO,GAAG,MAAW,KAAA,QAAA,IAAY,GAAG,MAAW,KAAA,CAAA;AACtF","file":"index.cjs","sourcesContent":["import { NonPromise } from './generic'\n\n/**\n * By declare a unique field `type` in each class, it ensure that the instance of one class can not\n * be assigned to a variable of another class. Furthermore, it also help to distinguish the type of\n * the instance at runtime.\n * By private the constructor, it ensure that the instance of the class can only be created by the\n * static method `from`, and which can enforce the type of the input parameter should not be a promise.\n * Finally, it will be helpful for the compiler to infer the type of the instance and avoid the mistake.\n */\n\n/**\n * TransactionHash represents a transaction hash.\n */\nexport type TransactionHash = string | number\n\n/**\n * Block represents a block.\n */\nexport class Block {\n readonly type = 'Block'\n private constructor(public block: unknown) {}\n\n /**\n * Creates an instance of Block from a non-promise value.\n *\n * @param {NonPromise<T>} raw - The raw value to create the Block from.\n * @returns {Block} The created Block instance.\n */\n static from<T>(raw: NonPromise<T>): Block {\n return new Block(raw)\n }\n}\n\n/**\n * BlockWithTransactions represents a block with transactions.\n */\nexport class BlockWithTransactions {\n readonly type = 'BlockWithTransactions'\n private constructor(public block: unknown) {}\n\n /**\n * Creates an instance of BlockWithTransactions from a non-promise value.\n *\n * @param {NonPromise<T>} raw - The raw value to create the BlockWithTransactions from.\n * @returns {BlockWithTransactions} The created BlockWithTransactions instance.\n */\n static from<T>(raw: NonPromise<T>): BlockWithTransactions {\n return new BlockWithTransactions(raw)\n }\n}\n\n/**\n * BlockTag represents a block tag.\n */\nexport type BlockTag = string | number\n\n/**\n * Finality represents the finality of a block.\n */\nexport type Finality = 'confirmed' | 'finalized'\n\n/**\n * A union type to represent all the possible types of a transaction.\n */\ntype TransactionTypes =\n | TransactionRequest\n | TransactionResponse\n | TransactionReceipt\n | SignedTransaction\n | TransactionPending\n\n/**\n * TransactionRequest represents the request of a transaction.\n */\nexport class TransactionRequest {\n readonly type = 'TransactionRequest'\n private constructor(public request: unknown) {}\n\n /**\n * Creates an instance of TransactionRequest from a non-promise value.\n *\n * @param {Exclude<NonPromise<T>, TransactionTypes>} raw - The raw value to create the TransactionRequest from.\n * @returns {TransactionRequest} The created TransactionRequest instance.\n */\n static from<T>(raw: Exclude<NonPromise<T>, TransactionTypes>): TransactionRequest {\n return new TransactionRequest(raw)\n }\n}\n\n/**\n * TransactionResponse represents the response of a transaction.\n */\nexport class TransactionResponse {\n readonly type = 'TransactionResponse'\n private constructor(public response: unknown) {}\n\n /**\n * Creates an instance of TransactionResponse from a non-promise value.\n *\n * @param {Exclude<NonPromise<T>, TransactionTypes>} raw - The raw value to create the TransactionResponse from.\n * @returns {TransactionResponse} The created TransactionResponse instance.\n */\n static from<T>(raw: Exclude<NonPromise<T>, TransactionTypes>): TransactionResponse {\n return new TransactionResponse(raw)\n }\n}\n\n/**\n * TransactionReceipt represents the receipt of a transaction.\n */\nexport class TransactionReceipt {\n readonly type = 'TransactionReceipt'\n private constructor(public receipt: unknown) {}\n\n /**\n * Creates an instance of TransactionReceipt from a non-promise value.\n *\n * @param {Exclude<NonPromise<T>, TransactionTypes>} raw - The raw value to create the TransactionReceipt from.\n * @returns {TransactionReceipt} The created TransactionReceipt instance.\n */\n static from<T>(raw: Exclude<NonPromise<T>, TransactionTypes>): TransactionReceipt {\n return new TransactionReceipt(raw)\n }\n}\n\n/**\n * SignedTransaction represents a signed transaction.\n */\nexport class SignedTransaction {\n readonly type = 'SignedTransaction'\n private constructor(public signed: unknown) {}\n\n /**\n * Creates an instance of SignedTransaction from a non-promise value.\n *\n * @param {Exclude<NonPromise<T>, TransactionTypes>} raw - The raw value to create the SignedTransaction from.\n * @returns {SignedTransaction} The created SignedTransaction instance.\n */\n static from<T>(raw: Exclude<NonPromise<T>, TransactionTypes>): SignedTransaction {\n return new SignedTransaction(raw)\n }\n}\n\n/**\n * TransactionPending represents a pending transaction.\n */\nexport class TransactionPending {\n readonly type = 'TransactionPending'\n private constructor(public pending: unknown) {}\n\n /**\n * Creates an instance of TransactionPending from a non-promise value.\n *\n * @param {Exclude<NonPromise<T>, TransactionTypes>} raw - The raw value to create the TransactionPending from.\n * @returns {TransactionPending} The created TransactionPending instance.\n */\n static from<T>(raw: Exclude<NonPromise<T>, TransactionTypes>): TransactionPending {\n return new TransactionPending(raw)\n }\n}\n","import { Provider } from './provider'\nimport { SignedTransaction, TransactionPending, TransactionReceipt, TransactionRequest } from './transaction'\n\n/**\n * Interface representing a signer.\n *\n */\nexport interface Signer {\n /**\n * Connect to a provider.\n *\n * @param {Provider} provider - The provider to connect to.\n * @returns {Signer} The connected signer.\n */\n connect(provider: Provider): Signer\n\n /**\n * Sign a transaction.\n *\n * @param {TransactionRequest} transaction - The transaction request to sign.\n * @returns {Promise<SignedTransaction>} A promise that resolves to the signed transaction.\n */\n signTransaction(transaction: TransactionRequest): Promise<SignedTransaction>\n\n /**\n * Send a transaction.\n *\n * @param {SignedTransaction} transaction - The signed transaction to send.\n * @param {unknown} [sendOptions] - Optional parameters for sending the transaction.\n * @returns {Promise<TransactionPending>} A promise that resolves to the pending transaction.\n */\n sendTransaction(transaction: SignedTransaction, sendOptions?: unknown): Promise<TransactionPending>\n\n /**\n * Send a transaction and wait for confirmation.\n *\n * @param {SignedTransaction} transaction - The signed transaction to send.\n * @param {unknown} [opts] - Optional parameters for sending and confirming the transaction.\n * @returns {Promise<TransactionReceipt>} A promise that resolves to the transaction receipt.\n */\n sendAndConfirm(transaction: SignedTransaction, opts?: unknown): Promise<TransactionReceipt>\n\n /**\n * Sign a buffer (e.g. a message hash) with the native function.\n *\n * @param {Uint8Array} buffer - The buffer to sign.\n * @returns {Promise<Uint8Array>} A promise that resolves to the signed buffer.\n */\n signBuffer(buffer: Uint8Array): Promise<Uint8Array>\n\n /**\n * Get the address of the signer.\n * this function NEED to return a Promise because ethers.Signer.getAddress() return a Promise<string>\n *\n * @returns {Promise<string>} A promise that resolves to the address of the signer.\n */\n getAddress(): Promise<string>\n\n /**\n * Native signer object\n */\n native: unknown\n}\n\n/**\n * Interface representing a connectable object.\n *\n * @template T - The type of the connectable object.\n */\nexport interface Connectable<T> {\n /**\n * Connect to a provider.\n *\n * @template U - The type of the provider.\n * @param {U} provider - The provider to connect to.\n * @returns {T} The connected object.\n */\n connect<U>(provider: U): T\n}\n\n/**\n * Check if an object is connectable.\n *\n * @template T - The type of the connectable object.\n * @param {unknown} obj - The object to check.\n * @returns {obj is Connectable<T>} True if the object is connectable, false otherwise.\n */\nexport function isConnectable<T>(obj: unknown): obj is Connectable<T> {\n if (typeof obj !== 'object' || obj === null) return false\n const fn = (obj as { connect?: unknown }).connect\n return typeof fn === 'function' && typeof fn.length === 'number' && fn.length === 1\n}\n"]}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,11 +1,48 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
*
|
|
6
|
-
*
|
|
2
|
+
* Utility types for manipulating types in TypeScript.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Exclude promise types from the given type.
|
|
6
|
+
* If the type is a promise, it returns `never`, otherwise it returns the original type.
|
|
7
7
|
*/
|
|
8
8
|
type NonPromise<T> = T extends Promise<unknown> ? never : T;
|
|
9
|
+
/**
|
|
10
|
+
* Extracts a nested property from an object type.
|
|
11
|
+
*
|
|
12
|
+
* @template T - The object type from which to extract the nested property.
|
|
13
|
+
* @template K - The string representing the nested property to extract.
|
|
14
|
+
* @returns A new object type containing the extracted nested property.
|
|
15
|
+
*/
|
|
16
|
+
type DeepPick<T, K extends string> = K extends `${infer F}.${infer R}` ? F extends keyof T ? {
|
|
17
|
+
[P in F]: DeepPick<T[F], R>;
|
|
18
|
+
} : never : K extends keyof T ? {
|
|
19
|
+
[P in K]: T[P];
|
|
20
|
+
} : never;
|
|
21
|
+
/**
|
|
22
|
+
* Converts a union type to an intersection type.
|
|
23
|
+
*
|
|
24
|
+
* @typeParam U - The union type to convert.
|
|
25
|
+
* @returns The resulting intersection type.
|
|
26
|
+
*/
|
|
27
|
+
type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
|
|
28
|
+
/**
|
|
29
|
+
* Represents a type that merges the intersection of all object properties recursively.
|
|
30
|
+
* If the input type is an object, it will merge the intersection of all its properties.
|
|
31
|
+
* Otherwise, it will return the input type as is.
|
|
32
|
+
*
|
|
33
|
+
* @typeParam T - The input type to merge the intersection of its properties.
|
|
34
|
+
* @returns The type that merges the intersection of all object properties recursively.
|
|
35
|
+
*/
|
|
36
|
+
type MergeIntersection<T> = T extends object ? {
|
|
37
|
+
[K in keyof T]: MergeIntersection<T[K]>;
|
|
38
|
+
} : T;
|
|
39
|
+
/**
|
|
40
|
+
* Represents a type that selects and merges properties from a union type based on a specified key.
|
|
41
|
+
*
|
|
42
|
+
* @template T - The type from which to select properties.
|
|
43
|
+
* @template K - The key to select properties from the type.
|
|
44
|
+
*/
|
|
45
|
+
type Choose<T, K extends string> = MergeIntersection<UnionToIntersection<DeepPick<T, K>>>;
|
|
9
46
|
|
|
10
47
|
/**
|
|
11
48
|
* By declare a unique field `type` in each class, it ensure that the instance of one class can not
|
|
@@ -265,7 +302,7 @@ interface Signer {
|
|
|
265
302
|
*/
|
|
266
303
|
sendAndConfirm(transaction: SignedTransaction, opts?: unknown): Promise<TransactionReceipt>;
|
|
267
304
|
/**
|
|
268
|
-
* Sign a buffer (e.g. a message hash).
|
|
305
|
+
* Sign a buffer (e.g. a message hash) with the native function.
|
|
269
306
|
*
|
|
270
307
|
* @param {Uint8Array} buffer - The buffer to sign.
|
|
271
308
|
* @returns {Promise<Uint8Array>} A promise that resolves to the signed buffer.
|
|
@@ -307,4 +344,4 @@ interface Connectable<T> {
|
|
|
307
344
|
*/
|
|
308
345
|
declare function isConnectable<T>(obj: unknown): obj is Connectable<T>;
|
|
309
346
|
|
|
310
|
-
export { Block, type BlockTag, BlockWithTransactions, type Connectable, type Finality, type Provider, SignedTransaction, type Signer, type TransactionHash, TransactionPending, TransactionReceipt, TransactionRequest, TransactionResponse, isConnectable };
|
|
347
|
+
export { Block, type BlockTag, BlockWithTransactions, type Choose, type Connectable, type Finality, type NonPromise, type Provider, SignedTransaction, type Signer, type TransactionHash, TransactionPending, TransactionReceipt, TransactionRequest, TransactionResponse, isConnectable };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,48 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
*
|
|
6
|
-
*
|
|
2
|
+
* Utility types for manipulating types in TypeScript.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Exclude promise types from the given type.
|
|
6
|
+
* If the type is a promise, it returns `never`, otherwise it returns the original type.
|
|
7
7
|
*/
|
|
8
8
|
type NonPromise<T> = T extends Promise<unknown> ? never : T;
|
|
9
|
+
/**
|
|
10
|
+
* Extracts a nested property from an object type.
|
|
11
|
+
*
|
|
12
|
+
* @template T - The object type from which to extract the nested property.
|
|
13
|
+
* @template K - The string representing the nested property to extract.
|
|
14
|
+
* @returns A new object type containing the extracted nested property.
|
|
15
|
+
*/
|
|
16
|
+
type DeepPick<T, K extends string> = K extends `${infer F}.${infer R}` ? F extends keyof T ? {
|
|
17
|
+
[P in F]: DeepPick<T[F], R>;
|
|
18
|
+
} : never : K extends keyof T ? {
|
|
19
|
+
[P in K]: T[P];
|
|
20
|
+
} : never;
|
|
21
|
+
/**
|
|
22
|
+
* Converts a union type to an intersection type.
|
|
23
|
+
*
|
|
24
|
+
* @typeParam U - The union type to convert.
|
|
25
|
+
* @returns The resulting intersection type.
|
|
26
|
+
*/
|
|
27
|
+
type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
|
|
28
|
+
/**
|
|
29
|
+
* Represents a type that merges the intersection of all object properties recursively.
|
|
30
|
+
* If the input type is an object, it will merge the intersection of all its properties.
|
|
31
|
+
* Otherwise, it will return the input type as is.
|
|
32
|
+
*
|
|
33
|
+
* @typeParam T - The input type to merge the intersection of its properties.
|
|
34
|
+
* @returns The type that merges the intersection of all object properties recursively.
|
|
35
|
+
*/
|
|
36
|
+
type MergeIntersection<T> = T extends object ? {
|
|
37
|
+
[K in keyof T]: MergeIntersection<T[K]>;
|
|
38
|
+
} : T;
|
|
39
|
+
/**
|
|
40
|
+
* Represents a type that selects and merges properties from a union type based on a specified key.
|
|
41
|
+
*
|
|
42
|
+
* @template T - The type from which to select properties.
|
|
43
|
+
* @template K - The key to select properties from the type.
|
|
44
|
+
*/
|
|
45
|
+
type Choose<T, K extends string> = MergeIntersection<UnionToIntersection<DeepPick<T, K>>>;
|
|
9
46
|
|
|
10
47
|
/**
|
|
11
48
|
* By declare a unique field `type` in each class, it ensure that the instance of one class can not
|
|
@@ -265,7 +302,7 @@ interface Signer {
|
|
|
265
302
|
*/
|
|
266
303
|
sendAndConfirm(transaction: SignedTransaction, opts?: unknown): Promise<TransactionReceipt>;
|
|
267
304
|
/**
|
|
268
|
-
* Sign a buffer (e.g. a message hash).
|
|
305
|
+
* Sign a buffer (e.g. a message hash) with the native function.
|
|
269
306
|
*
|
|
270
307
|
* @param {Uint8Array} buffer - The buffer to sign.
|
|
271
308
|
* @returns {Promise<Uint8Array>} A promise that resolves to the signed buffer.
|
|
@@ -307,4 +344,4 @@ interface Connectable<T> {
|
|
|
307
344
|
*/
|
|
308
345
|
declare function isConnectable<T>(obj: unknown): obj is Connectable<T>;
|
|
309
346
|
|
|
310
|
-
export { Block, type BlockTag, BlockWithTransactions, type Connectable, type Finality, type Provider, SignedTransaction, type Signer, type TransactionHash, TransactionPending, TransactionReceipt, TransactionRequest, TransactionResponse, isConnectable };
|
|
347
|
+
export { Block, type BlockTag, BlockWithTransactions, type Choose, type Connectable, type Finality, type NonPromise, type Provider, SignedTransaction, type Signer, type TransactionHash, TransactionPending, TransactionReceipt, TransactionRequest, TransactionResponse, isConnectable };
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/transaction.ts","../src/signer.ts"],"names":[],"mappings":";AAmBa,IAAA,KAAA,GAAN,MAAM,MAAM,CAAA;AAAA,EAEP,YAAmB,KAAgB,EAAA;AAAhB,IAAA,IAAA,CAAA,KAAA,GAAA,KAAA;AAD3B,IAAA,IAAA,CAAS,IAAO,GAAA,OAAA;AAAA;AAC4B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQ5C,OAAO,KAAQ,GAA2B,EAAA;AACtC,IAAO,OAAA,IAAI,OAAM,GAAG,CAAA;AAAA;AAE5B;AAKa,IAAA,qBAAA,GAAN,MAAM,sBAAsB,CAAA;AAAA,EAEvB,YAAmB,KAAgB,EAAA;AAAhB,IAAA,IAAA,CAAA,KAAA,GAAA,KAAA;AAD3B,IAAA,IAAA,CAAS,IAAO,GAAA,uBAAA;AAAA;AAC4B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQ5C,OAAO,KAAQ,GAA2C,EAAA;AACtD,IAAO,OAAA,IAAI,uBAAsB,GAAG,CAAA;AAAA;AAE5C;AAyBa,IAAA,kBAAA,GAAN,MAAM,mBAAmB,CAAA;AAAA,EAEpB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,EAEpB,YAAmB,OAAkB,EAAA;AAAlB,IAAA,IAAA,CAAA,OAAA,GAAA,OAAA;AAD3B,IAAA,IAAA,CAAS,IAAO,GAAA,oBAAA;AAAA;AAC8B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQ9C,OAAO,KAAQ,GAAmE,EAAA;AAC9E,IAAO,OAAA,IAAI,oBAAmB,GAAG,CAAA;AAAA;AAEzC;;;ACzEO,SAAS,cAAiB,GAAqC,EAAA;AAClE,EAAA,IAAI,OAAO,GAAA,KAAQ,QAAY,IAAA,GAAA,KAAQ,MAAa,OAAA,KAAA;AACpD,EAAA,MAAM,KAAM,GAA8B,CAAA,OAAA;AAC1C,EAAO,OAAA,OAAO,OAAO,UAAc,IAAA,OAAO,GAAG,MAAW,KAAA,QAAA,IAAY,GAAG,MAAW,KAAA,CAAA;AACtF","file":"index.mjs","sourcesContent":["import { NonPromise } from './promise'\n\n/**\n * By declare a unique field `type` in each class, it ensure that the instance of one class can not\n * be assigned to a variable of another class. Furthermore, it also help to distinguish the type of\n * the instance at runtime.\n * By private the constructor, it ensure that the instance of the class can only be created by the\n * static method `from`, and which can enforce the type of the input parameter should not be a promise.\n * Finally, it will be helpful for the compiler to infer the type of the instance and avoid the mistake.\n */\n\n/**\n * TransactionHash represents a transaction hash.\n */\nexport type TransactionHash = string | number\n\n/**\n * Block represents a block.\n */\nexport class Block {\n readonly type = 'Block'\n private constructor(public block: unknown) {}\n\n /**\n * Creates an instance of Block from a non-promise value.\n *\n * @param {NonPromise<T>} raw - The raw value to create the Block from.\n * @returns {Block} The created Block instance.\n */\n static from<T>(raw: NonPromise<T>): Block {\n return new Block(raw)\n }\n}\n\n/**\n * BlockWithTransactions represents a block with transactions.\n */\nexport class BlockWithTransactions {\n readonly type = 'BlockWithTransactions'\n private constructor(public block: unknown) {}\n\n /**\n * Creates an instance of BlockWithTransactions from a non-promise value.\n *\n * @param {NonPromise<T>} raw - The raw value to create the BlockWithTransactions from.\n * @returns {BlockWithTransactions} The created BlockWithTransactions instance.\n */\n static from<T>(raw: NonPromise<T>): BlockWithTransactions {\n return new BlockWithTransactions(raw)\n }\n}\n\n/**\n * BlockTag represents a block tag.\n */\nexport type BlockTag = string | number\n\n/**\n * Finality represents the finality of a block.\n */\nexport type Finality = 'confirmed' | 'finalized'\n\n/**\n * A union type to represent all the possible types of a transaction.\n */\ntype TransactionTypes =\n | TransactionRequest\n | TransactionResponse\n | TransactionReceipt\n | SignedTransaction\n | TransactionPending\n\n/**\n * TransactionRequest represents the request of a transaction.\n */\nexport class TransactionRequest {\n readonly type = 'TransactionRequest'\n private constructor(public request: unknown) {}\n\n /**\n * Creates an instance of TransactionRequest from a non-promise value.\n *\n * @param {Exclude<NonPromise<T>, TransactionTypes>} raw - The raw value to create the TransactionRequest from.\n * @returns {TransactionRequest} The created TransactionRequest instance.\n */\n static from<T>(raw: Exclude<NonPromise<T>, TransactionTypes>): TransactionRequest {\n return new TransactionRequest(raw)\n }\n}\n\n/**\n * TransactionResponse represents the response of a transaction.\n */\nexport class TransactionResponse {\n readonly type = 'TransactionResponse'\n private constructor(public response: unknown) {}\n\n /**\n * Creates an instance of TransactionResponse from a non-promise value.\n *\n * @param {Exclude<NonPromise<T>, TransactionTypes>} raw - The raw value to create the TransactionResponse from.\n * @returns {TransactionResponse} The created TransactionResponse instance.\n */\n static from<T>(raw: Exclude<NonPromise<T>, TransactionTypes>): TransactionResponse {\n return new TransactionResponse(raw)\n }\n}\n\n/**\n * TransactionReceipt represents the receipt of a transaction.\n */\nexport class TransactionReceipt {\n readonly type = 'TransactionReceipt'\n private constructor(public receipt: unknown) {}\n\n /**\n * Creates an instance of TransactionReceipt from a non-promise value.\n *\n * @param {Exclude<NonPromise<T>, TransactionTypes>} raw - The raw value to create the TransactionReceipt from.\n * @returns {TransactionReceipt} The created TransactionReceipt instance.\n */\n static from<T>(raw: Exclude<NonPromise<T>, TransactionTypes>): TransactionReceipt {\n return new TransactionReceipt(raw)\n }\n}\n\n/**\n * SignedTransaction represents a signed transaction.\n */\nexport class SignedTransaction {\n readonly type = 'SignedTransaction'\n private constructor(public signed: unknown) {}\n\n /**\n * Creates an instance of SignedTransaction from a non-promise value.\n *\n * @param {Exclude<NonPromise<T>, TransactionTypes>} raw - The raw value to create the SignedTransaction from.\n * @returns {SignedTransaction} The created SignedTransaction instance.\n */\n static from<T>(raw: Exclude<NonPromise<T>, TransactionTypes>): SignedTransaction {\n return new SignedTransaction(raw)\n }\n}\n\n/**\n * TransactionPending represents a pending transaction.\n */\nexport class TransactionPending {\n readonly type = 'TransactionPending'\n private constructor(public pending: unknown) {}\n\n /**\n * Creates an instance of TransactionPending from a non-promise value.\n *\n * @param {Exclude<NonPromise<T>, TransactionTypes>} raw - The raw value to create the TransactionPending from.\n * @returns {TransactionPending} The created TransactionPending instance.\n */\n static from<T>(raw: Exclude<NonPromise<T>, TransactionTypes>): TransactionPending {\n return new TransactionPending(raw)\n }\n}\n","import { Provider } from './provider'\nimport { SignedTransaction, TransactionPending, TransactionReceipt, TransactionRequest } from './transaction'\n\n/**\n * Interface representing a signer.\n *\n */\nexport interface Signer {\n /**\n * Connect to a provider.\n *\n * @param {Provider} provider - The provider to connect to.\n * @returns {Signer} The connected signer.\n */\n connect(provider: Provider): Signer\n\n /**\n * Sign a transaction.\n *\n * @param {TransactionRequest} transaction - The transaction request to sign.\n * @returns {Promise<SignedTransaction>} A promise that resolves to the signed transaction.\n */\n signTransaction(transaction: TransactionRequest): Promise<SignedTransaction>\n\n /**\n * Send a transaction.\n *\n * @param {SignedTransaction} transaction - The signed transaction to send.\n * @param {unknown} [sendOptions] - Optional parameters for sending the transaction.\n * @returns {Promise<TransactionPending>} A promise that resolves to the pending transaction.\n */\n sendTransaction(transaction: SignedTransaction, sendOptions?: unknown): Promise<TransactionPending>\n\n /**\n * Send a transaction and wait for confirmation.\n *\n * @param {SignedTransaction} transaction - The signed transaction to send.\n * @param {unknown} [opts] - Optional parameters for sending and confirming the transaction.\n * @returns {Promise<TransactionReceipt>} A promise that resolves to the transaction receipt.\n */\n sendAndConfirm(transaction: SignedTransaction, opts?: unknown): Promise<TransactionReceipt>\n\n /**\n * Sign a buffer (e.g. a message hash).\n *\n * @param {Uint8Array} buffer - The buffer to sign.\n * @returns {Promise<Uint8Array>} A promise that resolves to the signed buffer.\n */\n signBuffer(buffer: Uint8Array): Promise<Uint8Array>\n\n /**\n * Get the address of the signer.\n * this function NEED to return a Promise because ethers.Signer.getAddress() return a Promise<string>\n *\n * @returns {Promise<string>} A promise that resolves to the address of the signer.\n */\n getAddress(): Promise<string>\n\n /**\n * Native signer object\n */\n native: unknown\n}\n\n/**\n * Interface representing a connectable object.\n *\n * @template T - The type of the connectable object.\n */\nexport interface Connectable<T> {\n /**\n * Connect to a provider.\n *\n * @template U - The type of the provider.\n * @param {U} provider - The provider to connect to.\n * @returns {T} The connected object.\n */\n connect<U>(provider: U): T\n}\n\n/**\n * Check if an object is connectable.\n *\n * @template T - The type of the connectable object.\n * @param {unknown} obj - The object to check.\n * @returns {obj is Connectable<T>} True if the object is connectable, false otherwise.\n */\nexport function isConnectable<T>(obj: unknown): obj is Connectable<T> {\n if (typeof obj !== 'object' || obj === null) return false\n const fn = (obj as { connect?: unknown }).connect\n return typeof fn === 'function' && typeof fn.length === 'number' && fn.length === 1\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/transaction.ts","../src/signer.ts"],"names":[],"mappings":";AAmBa,IAAA,KAAA,GAAN,MAAM,MAAM,CAAA;AAAA,EAEP,YAAmB,KAAgB,EAAA;AAAhB,IAAA,IAAA,CAAA,KAAA,GAAA,KAAA;AAD3B,IAAA,IAAA,CAAS,IAAO,GAAA,OAAA;AAAA;AAC4B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQ5C,OAAO,KAAQ,GAA2B,EAAA;AACtC,IAAO,OAAA,IAAI,OAAM,GAAG,CAAA;AAAA;AAE5B;AAKa,IAAA,qBAAA,GAAN,MAAM,sBAAsB,CAAA;AAAA,EAEvB,Y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EAEnB,YAAmB,MAAiB,EAAA;AAAjB,IAAA,IAAA,CAAA,MAAA,GAAA,MAAA;AAD3B,IAAA,IAAA,CAAS,IAAO,GAAA,mBAAA;AAAA;AAC6B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQ7C,OAAO,KAAQ,GAAkE,EAAA;AAC7E,IAAO,OAAA,IAAI,mBAAkB,GAAG,CAAA;AAAA;AAExC;AAKa,IAAA,kBAAA,GAAN,MAAM,mBAAmB,CAAA;AAAA,EAEpB,YAAmB,OAAkB,EAAA;AAAlB,IAAA,IAAA,CAAA,OAAA,GAAA,OAAA;AAD3B,IAAA,IAAA,CAAS,IAAO,GAAA,oBAAA;AAAA;AAC8B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQ9C,OAAO,KAAQ,GAAmE,EAAA;AAC9E,IAAO,OAAA,IAAI,oBAAmB,GAAG,CAAA;AAAA;AAEzC;;;ACzEO,SAAS,cAAiB,GAAqC,EAAA;AAClE,EAAA,IAAI,OAAO,GAAA,KAAQ,QAAY,IAAA,GAAA,KAAQ,MAAa,OAAA,KAAA;AACpD,EAAA,MAAM,KAAM,GAA8B,CAAA,OAAA;AAC1C,EAAO,OAAA,OAAO,OAAO,UAAc,IAAA,OAAO,GAAG,MAAW,KAAA,QAAA,IAAY,GAAG,MAAW,KAAA,CAAA;AACtF","file":"index.mjs","sourcesContent":["import { NonPromise } from './generic'\n\n/**\n * By declare a unique field `type` in each class, it ensure that the instance of one class can not\n * be assigned to a variable of another class. Furthermore, it also help to distinguish the type of\n * the instance at runtime.\n * By private the constructor, it ensure that the instance of the class can only be created by the\n * static method `from`, and which can enforce the type of the input parameter should not be a promise.\n * Finally, it will be helpful for the compiler to infer the type of the instance and avoid the mistake.\n */\n\n/**\n * TransactionHash represents a transaction hash.\n */\nexport type TransactionHash = string | number\n\n/**\n * Block represents a block.\n */\nexport class Block {\n readonly type = 'Block'\n private constructor(public block: unknown) {}\n\n /**\n * Creates an instance of Block from a non-promise value.\n *\n * @param {NonPromise<T>} raw - The raw value to create the Block from.\n * @returns {Block} The created Block instance.\n */\n static from<T>(raw: NonPromise<T>): Block {\n return new Block(raw)\n }\n}\n\n/**\n * BlockWithTransactions represents a block with transactions.\n */\nexport class BlockWithTransactions {\n readonly type = 'BlockWithTransactions'\n private constructor(public block: unknown) {}\n\n /**\n * Creates an instance of BlockWithTransactions from a non-promise value.\n *\n * @param {NonPromise<T>} raw - The raw value to create the BlockWithTransactions from.\n * @returns {BlockWithTransactions} The created BlockWithTransactions instance.\n */\n static from<T>(raw: NonPromise<T>): BlockWithTransactions {\n return new BlockWithTransactions(raw)\n }\n}\n\n/**\n * BlockTag represents a block tag.\n */\nexport type BlockTag = string | number\n\n/**\n * Finality represents the finality of a block.\n */\nexport type Finality = 'confirmed' | 'finalized'\n\n/**\n * A union type to represent all the possible types of a transaction.\n */\ntype TransactionTypes =\n | TransactionRequest\n | TransactionResponse\n | TransactionReceipt\n | SignedTransaction\n | TransactionPending\n\n/**\n * TransactionRequest represents the request of a transaction.\n */\nexport class TransactionRequest {\n readonly type = 'TransactionRequest'\n private constructor(public request: unknown) {}\n\n /**\n * Creates an instance of TransactionRequest from a non-promise value.\n *\n * @param {Exclude<NonPromise<T>, TransactionTypes>} raw - The raw value to create the TransactionRequest from.\n * @returns {TransactionRequest} The created TransactionRequest instance.\n */\n static from<T>(raw: Exclude<NonPromise<T>, TransactionTypes>): TransactionRequest {\n return new TransactionRequest(raw)\n }\n}\n\n/**\n * TransactionResponse represents the response of a transaction.\n */\nexport class TransactionResponse {\n readonly type = 'TransactionResponse'\n private constructor(public response: unknown) {}\n\n /**\n * Creates an instance of TransactionResponse from a non-promise value.\n *\n * @param {Exclude<NonPromise<T>, TransactionTypes>} raw - The raw value to create the TransactionResponse from.\n * @returns {TransactionResponse} The created TransactionResponse instance.\n */\n static from<T>(raw: Exclude<NonPromise<T>, TransactionTypes>): TransactionResponse {\n return new TransactionResponse(raw)\n }\n}\n\n/**\n * TransactionReceipt represents the receipt of a transaction.\n */\nexport class TransactionReceipt {\n readonly type = 'TransactionReceipt'\n private constructor(public receipt: unknown) {}\n\n /**\n * Creates an instance of TransactionReceipt from a non-promise value.\n *\n * @param {Exclude<NonPromise<T>, TransactionTypes>} raw - The raw value to create the TransactionReceipt from.\n * @returns {TransactionReceipt} The created TransactionReceipt instance.\n */\n static from<T>(raw: Exclude<NonPromise<T>, TransactionTypes>): TransactionReceipt {\n return new TransactionReceipt(raw)\n }\n}\n\n/**\n * SignedTransaction represents a signed transaction.\n */\nexport class SignedTransaction {\n readonly type = 'SignedTransaction'\n private constructor(public signed: unknown) {}\n\n /**\n * Creates an instance of SignedTransaction from a non-promise value.\n *\n * @param {Exclude<NonPromise<T>, TransactionTypes>} raw - The raw value to create the SignedTransaction from.\n * @returns {SignedTransaction} The created SignedTransaction instance.\n */\n static from<T>(raw: Exclude<NonPromise<T>, TransactionTypes>): SignedTransaction {\n return new SignedTransaction(raw)\n }\n}\n\n/**\n * TransactionPending represents a pending transaction.\n */\nexport class TransactionPending {\n readonly type = 'TransactionPending'\n private constructor(public pending: unknown) {}\n\n /**\n * Creates an instance of TransactionPending from a non-promise value.\n *\n * @param {Exclude<NonPromise<T>, TransactionTypes>} raw - The raw value to create the TransactionPending from.\n * @returns {TransactionPending} The created TransactionPending instance.\n */\n static from<T>(raw: Exclude<NonPromise<T>, TransactionTypes>): TransactionPending {\n return new TransactionPending(raw)\n }\n}\n","import { Provider } from './provider'\nimport { SignedTransaction, TransactionPending, TransactionReceipt, TransactionRequest } from './transaction'\n\n/**\n * Interface representing a signer.\n *\n */\nexport interface Signer {\n /**\n * Connect to a provider.\n *\n * @param {Provider} provider - The provider to connect to.\n * @returns {Signer} The connected signer.\n */\n connect(provider: Provider): Signer\n\n /**\n * Sign a transaction.\n *\n * @param {TransactionRequest} transaction - The transaction request to sign.\n * @returns {Promise<SignedTransaction>} A promise that resolves to the signed transaction.\n */\n signTransaction(transaction: TransactionRequest): Promise<SignedTransaction>\n\n /**\n * Send a transaction.\n *\n * @param {SignedTransaction} transaction - The signed transaction to send.\n * @param {unknown} [sendOptions] - Optional parameters for sending the transaction.\n * @returns {Promise<TransactionPending>} A promise that resolves to the pending transaction.\n */\n sendTransaction(transaction: SignedTransaction, sendOptions?: unknown): Promise<TransactionPending>\n\n /**\n * Send a transaction and wait for confirmation.\n *\n * @param {SignedTransaction} transaction - The signed transaction to send.\n * @param {unknown} [opts] - Optional parameters for sending and confirming the transaction.\n * @returns {Promise<TransactionReceipt>} A promise that resolves to the transaction receipt.\n */\n sendAndConfirm(transaction: SignedTransaction, opts?: unknown): Promise<TransactionReceipt>\n\n /**\n * Sign a buffer (e.g. a message hash) with the native function.\n *\n * @param {Uint8Array} buffer - The buffer to sign.\n * @returns {Promise<Uint8Array>} A promise that resolves to the signed buffer.\n */\n signBuffer(buffer: Uint8Array): Promise<Uint8Array>\n\n /**\n * Get the address of the signer.\n * this function NEED to return a Promise because ethers.Signer.getAddress() return a Promise<string>\n *\n * @returns {Promise<string>} A promise that resolves to the address of the signer.\n */\n getAddress(): Promise<string>\n\n /**\n * Native signer object\n */\n native: unknown\n}\n\n/**\n * Interface representing a connectable object.\n *\n * @template T - The type of the connectable object.\n */\nexport interface Connectable<T> {\n /**\n * Connect to a provider.\n *\n * @template U - The type of the provider.\n * @param {U} provider - The provider to connect to.\n * @returns {T} The connected object.\n */\n connect<U>(provider: U): T\n}\n\n/**\n * Check if an object is connectable.\n *\n * @template T - The type of the connectable object.\n * @param {unknown} obj - The object to check.\n * @returns {obj is Connectable<T>} True if the object is connectable, false otherwise.\n */\nexport function isConnectable<T>(obj: unknown): obj is Connectable<T> {\n if (typeof obj !== 'object' || obj === null) return false\n const fn = (obj as { connect?: unknown }).connect\n return typeof fn === 'function' && typeof fn.length === 'number' && fn.length === 1\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@layerzerolabs/lz-core",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.68-ton.0",
|
|
4
4
|
"description": "LayerZero Core Library",
|
|
5
5
|
"license": "BUSL-1.1",
|
|
6
6
|
"exports": {
|
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@jest/globals": "^29.7.0",
|
|
27
|
-
"@layerzerolabs/tsup-config-next": "^3.0.
|
|
28
|
-
"@layerzerolabs/typescript-config-next": "^3.0.
|
|
27
|
+
"@layerzerolabs/tsup-config-next": "^3.0.68-ton.0",
|
|
28
|
+
"@layerzerolabs/typescript-config-next": "^3.0.68-ton.0",
|
|
29
29
|
"@types/jest": "^29.5.10",
|
|
30
30
|
"jest": "^29.7.0",
|
|
31
31
|
"rimraf": "^5.0.5",
|