@layerzerolabs/lz-core 2.1.23
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 +8 -0
- package/README.md +1 -0
- package/dist/index.cjs +81 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.mts +188 -0
- package/dist/index.d.ts +188 -0
- package/dist/index.mjs +72 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +42 -0
package/CHANGELOG.md
ADDED
package/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# layerzero-core
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// src/transaction.ts
|
|
4
|
+
var Block = class _Block {
|
|
5
|
+
constructor(block) {
|
|
6
|
+
this.block = block;
|
|
7
|
+
this.type = "Block";
|
|
8
|
+
}
|
|
9
|
+
static from(raw) {
|
|
10
|
+
return new _Block(raw);
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
var BlockWithTransactions = class _BlockWithTransactions {
|
|
14
|
+
constructor(block) {
|
|
15
|
+
this.block = block;
|
|
16
|
+
this.type = "BlockWithTransactions";
|
|
17
|
+
}
|
|
18
|
+
static from(raw) {
|
|
19
|
+
return new _BlockWithTransactions(raw);
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
var TransactionRequest = class _TransactionRequest {
|
|
23
|
+
constructor(request) {
|
|
24
|
+
this.request = request;
|
|
25
|
+
this.type = "TransactionRequest";
|
|
26
|
+
}
|
|
27
|
+
static from(raw) {
|
|
28
|
+
return new _TransactionRequest(raw);
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
var TransactionResponse = class _TransactionResponse {
|
|
32
|
+
constructor(response) {
|
|
33
|
+
this.response = response;
|
|
34
|
+
this.type = "TransactionResponse";
|
|
35
|
+
}
|
|
36
|
+
static from(raw) {
|
|
37
|
+
return new _TransactionResponse(raw);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
var TransactionReceipt = class _TransactionReceipt {
|
|
41
|
+
constructor(receipt) {
|
|
42
|
+
this.receipt = receipt;
|
|
43
|
+
this.type = "TransactionReceipt";
|
|
44
|
+
}
|
|
45
|
+
static from(raw) {
|
|
46
|
+
return new _TransactionReceipt(raw);
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
var SignedTransaction = class _SignedTransaction {
|
|
50
|
+
constructor(signed) {
|
|
51
|
+
this.signed = signed;
|
|
52
|
+
this.type = "SignedTransaction";
|
|
53
|
+
}
|
|
54
|
+
static from(raw) {
|
|
55
|
+
return new _SignedTransaction(raw);
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
var TransactionPending = class _TransactionPending {
|
|
59
|
+
constructor(pending) {
|
|
60
|
+
this.pending = pending;
|
|
61
|
+
this.type = "TransactionPending";
|
|
62
|
+
}
|
|
63
|
+
static from(raw) {
|
|
64
|
+
return new _TransactionPending(raw);
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
// src/signer.ts
|
|
69
|
+
var Signer = class {
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
exports.Block = Block;
|
|
73
|
+
exports.BlockWithTransactions = BlockWithTransactions;
|
|
74
|
+
exports.SignedTransaction = SignedTransaction;
|
|
75
|
+
exports.Signer = Signer;
|
|
76
|
+
exports.TransactionPending = TransactionPending;
|
|
77
|
+
exports.TransactionReceipt = TransactionReceipt;
|
|
78
|
+
exports.TransactionRequest = TransactionRequest;
|
|
79
|
+
exports.TransactionResponse = TransactionResponse;
|
|
80
|
+
//# sourceMappingURL=out.js.map
|
|
81
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/transaction.ts","../src/signer.ts"],"names":[],"mappings":";AAmBO,IAAM,QAAN,MAAM,OAAM;AAAA,EAEP,YAAmB,OAAgB;AAAhB;AAD3B,SAAS,OAAO;AAAA,EAC4B;AAAA,EAC5C,OAAO,KAAQ,KAA2B;AACtC,WAAO,IAAI,OAAM,GAAG;AAAA,EACxB;AACJ;AAKO,IAAM,wBAAN,MAAM,uBAAsB;AAAA,EAEvB,YAAmB,OAAgB;AAAhB;AAD3B,SAAS,OAAO;AAAA,EAC4B;AAAA,EAC5C,OAAO,KAAQ,KAA2C;AACtD,WAAO,IAAI,uBAAsB,GAAG;AAAA,EACxC;AACJ;AAeO,IAAM,qBAAN,MAAM,oBAAmB;AAAA,EAEpB,YAAmB,SAAkB;AAAlB;AAD3B,SAAS,OAAO;AAAA,EAC8B;AAAA,EAC9C,OAAO,KAAQ,KAAwC;AACnD,WAAO,IAAI,oBAAmB,GAAG;AAAA,EACrC;AACJ;AAKO,IAAM,sBAAN,MAAM,qBAAoB;AAAA,EAErB,YAAmB,UAAmB;AAAnB;AAD3B,SAAS,OAAO;AAAA,EAC+B;AAAA,EAC/C,OAAO,KAAQ,KAAyC;AACpD,WAAO,IAAI,qBAAoB,GAAG;AAAA,EACtC;AACJ;AAKO,IAAM,qBAAN,MAAM,oBAAmB;AAAA,EAEpB,YAAmB,SAAkB;AAAlB;AAD3B,SAAS,OAAO;AAAA,EAC8B;AAAA,EAC9C,OAAO,KAAQ,KAAwC;AACnD,WAAO,IAAI,oBAAmB,GAAG;AAAA,EACrC;AACJ;AAKO,IAAM,oBAAN,MAAM,mBAAkB;AAAA,EAEnB,YAAmB,QAAiB;AAAjB;AAD3B,SAAS,OAAO;AAAA,EAC6B;AAAA,EAC7C,OAAO,KAAQ,KAAuC;AAClD,WAAO,IAAI,mBAAkB,GAAG;AAAA,EACpC;AACJ;AAKO,IAAM,qBAAN,MAAM,oBAAmB;AAAA,EAEpB,YAAmB,SAAkB;AAAlB;AAD3B,SAAS,OAAO;AAAA,EAC8B;AAAA,EAC9C,OAAO,KAAQ,KAAwC;AACnD,WAAO,IAAI,oBAAmB,GAAG;AAAA,EACrC;AACJ;;;AClGO,IAAe,SAAf,MAAsB;AAyC7B","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 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 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 * TransactionRequest represents the request of a transaction.\n */\nexport class TransactionRequest {\n readonly type = 'TransactionRequest'\n private constructor(public request: unknown) {}\n static from<T>(raw: NonPromise<T>): 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 static from<T>(raw: NonPromise<T>): 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 static from<T>(raw: NonPromise<T>): 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 static from<T>(raw: NonPromise<T>): 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 static from<T>(raw: NonPromise<T>): TransactionPending {\n return new TransactionPending(raw)\n }\n}\n","import { Provider } from './provider'\nimport { SignedTransaction, TransactionPending, TransactionReceipt, TransactionRequest } from './transaction'\n\nexport abstract class Signer {\n /**\n * Connect to a provider\n * @param provider\n */\n abstract connect(provider: Provider): Signer\n\n /**\n * Sign a transaction\n * @param transaction\n */\n abstract signTransaction(transaction: TransactionRequest): Promise<SignedTransaction>\n\n /**\n * Send a transaction\n * @param transaction\n * @param sendOptions\n */\n abstract sendTransaction(transaction: SignedTransaction, sendOptions?: any): Promise<TransactionPending>\n\n /**\n * Send a transaction and wait for confirmation\n * @param transaction\n * @param opts\n */\n abstract sendAndConfirm(transaction: SignedTransaction, opts?: any): Promise<TransactionReceipt>\n\n /**\n * Sign a buffer (e.g. a message hash)\n */\n abstract signBuffer(buffer: Uint8Array): Promise<Uint8Array>\n\n /**\n * returns the address of the signer\n */\n abstract getAddress(): Promise<string>\n\n /**\n * Native signer object\n */\n native: unknown\n}\n"]}
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
type NonPromise<T> = T extends Promise<unknown> ? never : T;
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* By declare a unique field `type` in each class, it ensure that the instance of one class can not
|
|
5
|
+
* be assigned to a variable of another class. Furthermore, it also help to distinguish the type of
|
|
6
|
+
* the instance at runtime.
|
|
7
|
+
* By private the constructor, it ensure that the instance of the class can only be created by the
|
|
8
|
+
* static method `from`, and which can enforce the type of the input parameter should not be a promise.
|
|
9
|
+
* Finally, it will be helpful for the compiler to infer the type of the instance and avoid the mistake.
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* TransactionHash represents a transaction hash.
|
|
13
|
+
*/
|
|
14
|
+
type TransactionHash = string | number;
|
|
15
|
+
/**
|
|
16
|
+
* Block represents a block.
|
|
17
|
+
*/
|
|
18
|
+
declare class Block {
|
|
19
|
+
block: unknown;
|
|
20
|
+
readonly type = "Block";
|
|
21
|
+
private constructor();
|
|
22
|
+
static from<T>(raw: NonPromise<T>): Block;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* BlockWithTransactions represents a block with transactions.
|
|
26
|
+
*/
|
|
27
|
+
declare class BlockWithTransactions {
|
|
28
|
+
block: unknown;
|
|
29
|
+
readonly type = "BlockWithTransactions";
|
|
30
|
+
private constructor();
|
|
31
|
+
static from<T>(raw: NonPromise<T>): BlockWithTransactions;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* BlockTag represents a block tag.
|
|
35
|
+
*/
|
|
36
|
+
type BlockTag = string | number;
|
|
37
|
+
/**
|
|
38
|
+
* Finality represents the finality of a block.
|
|
39
|
+
*/
|
|
40
|
+
type Finality = 'confirmed' | 'finalized';
|
|
41
|
+
/**
|
|
42
|
+
* TransactionRequest represents the request of a transaction.
|
|
43
|
+
*/
|
|
44
|
+
declare class TransactionRequest {
|
|
45
|
+
request: unknown;
|
|
46
|
+
readonly type = "TransactionRequest";
|
|
47
|
+
private constructor();
|
|
48
|
+
static from<T>(raw: NonPromise<T>): TransactionRequest;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* TransactionResponse represents the response of a transaction.
|
|
52
|
+
*/
|
|
53
|
+
declare class TransactionResponse {
|
|
54
|
+
response: unknown;
|
|
55
|
+
readonly type = "TransactionResponse";
|
|
56
|
+
private constructor();
|
|
57
|
+
static from<T>(raw: NonPromise<T>): TransactionResponse;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* TransactionReceipt represents the receipt of a transaction.
|
|
61
|
+
*/
|
|
62
|
+
declare class TransactionReceipt {
|
|
63
|
+
receipt: unknown;
|
|
64
|
+
readonly type = "TransactionReceipt";
|
|
65
|
+
private constructor();
|
|
66
|
+
static from<T>(raw: NonPromise<T>): TransactionReceipt;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* SignedTransaction represents a signed transaction.
|
|
70
|
+
*/
|
|
71
|
+
declare class SignedTransaction {
|
|
72
|
+
signed: unknown;
|
|
73
|
+
readonly type = "SignedTransaction";
|
|
74
|
+
private constructor();
|
|
75
|
+
static from<T>(raw: NonPromise<T>): SignedTransaction;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* TransactionPending represents a pending transaction.
|
|
79
|
+
*/
|
|
80
|
+
declare class TransactionPending {
|
|
81
|
+
pending: unknown;
|
|
82
|
+
readonly type = "TransactionPending";
|
|
83
|
+
private constructor();
|
|
84
|
+
static from<T>(raw: NonPromise<T>): TransactionPending;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
interface Provider {
|
|
88
|
+
/**
|
|
89
|
+
* Get the block specified by blockTag
|
|
90
|
+
* @param {BlockTag} [blockTag]
|
|
91
|
+
* @returns
|
|
92
|
+
*/
|
|
93
|
+
getBlock(blockTag: BlockTag): Promise<Block>;
|
|
94
|
+
getBlockWithTransactions(blockTag: BlockTag): Promise<BlockWithTransactions>;
|
|
95
|
+
/**
|
|
96
|
+
* Get information about a transaction
|
|
97
|
+
* @param {string} txHash
|
|
98
|
+
* @returns
|
|
99
|
+
*/
|
|
100
|
+
getTransaction(txHash: string): Promise<TransactionResponse>;
|
|
101
|
+
/**
|
|
102
|
+
* Get the receipt of a transaction
|
|
103
|
+
* @param txHash
|
|
104
|
+
*/
|
|
105
|
+
getTransactionReceipt(txHash: string): Promise<TransactionReceipt>;
|
|
106
|
+
/**
|
|
107
|
+
* Get the current block number
|
|
108
|
+
* @returns Promise<number> the current block number
|
|
109
|
+
*/
|
|
110
|
+
getBlockNumber(): Promise<number>;
|
|
111
|
+
/**
|
|
112
|
+
* Get the current slot number for commitment
|
|
113
|
+
* @param commitment
|
|
114
|
+
*/
|
|
115
|
+
getSlot(commitment?: Finality): Promise<number>;
|
|
116
|
+
/**
|
|
117
|
+
* Get the number of transactions sent from this address
|
|
118
|
+
* @param {string|Promise<string>} addressOrName The address to get the numbers of transactions from
|
|
119
|
+
* @param {BlockTag|Promise<BlockTag>} [blockTag] The block tag to get the numbers of transactions from
|
|
120
|
+
* @returns Promise<number> The number of transactions sent from this address
|
|
121
|
+
*/
|
|
122
|
+
getTransactionCount(addressOrName: string | Promise<string>, blockTag?: BlockTag | Promise<BlockTag>): Promise<number>;
|
|
123
|
+
/**
|
|
124
|
+
* Get the balance of an address
|
|
125
|
+
* @param address
|
|
126
|
+
*/
|
|
127
|
+
getBalance(address: string): Promise<string>;
|
|
128
|
+
/**
|
|
129
|
+
* Gets the UNIX timestamp for the block identified by blockTag. The UNIX timestamp is defined as the count of
|
|
130
|
+
* seconds since the Unix Epoch on January 1st, 1970 at UTC. If blockTag is not provided, the latest block is used.
|
|
131
|
+
* @param {string?} blockTag
|
|
132
|
+
* @returns Promise<number> the UNIX timestamp of the block identified by blockTag
|
|
133
|
+
*/
|
|
134
|
+
getBlockTimestamp(blockTag: BlockTag): Promise<number>;
|
|
135
|
+
/**
|
|
136
|
+
* sendTransaction sends a signed transaction in bytes to the blockchain.
|
|
137
|
+
* @param transaction
|
|
138
|
+
* @param sendOptions
|
|
139
|
+
*/
|
|
140
|
+
sendTransaction(transaction: SignedTransaction, sendOptions?: any): Promise<TransactionPending>;
|
|
141
|
+
/**
|
|
142
|
+
* Send a transaction and wait for confirmation
|
|
143
|
+
* @param transaction
|
|
144
|
+
* @param opts
|
|
145
|
+
*/
|
|
146
|
+
sendAndConfirm(transaction: SignedTransaction, opts?: any): Promise<TransactionReceipt>;
|
|
147
|
+
readonly native: unknown;
|
|
148
|
+
connectedTo<T>(item: T): T;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
declare abstract class Signer {
|
|
152
|
+
/**
|
|
153
|
+
* Connect to a provider
|
|
154
|
+
* @param provider
|
|
155
|
+
*/
|
|
156
|
+
abstract connect(provider: Provider): Signer;
|
|
157
|
+
/**
|
|
158
|
+
* Sign a transaction
|
|
159
|
+
* @param transaction
|
|
160
|
+
*/
|
|
161
|
+
abstract signTransaction(transaction: TransactionRequest): Promise<SignedTransaction>;
|
|
162
|
+
/**
|
|
163
|
+
* Send a transaction
|
|
164
|
+
* @param transaction
|
|
165
|
+
* @param sendOptions
|
|
166
|
+
*/
|
|
167
|
+
abstract sendTransaction(transaction: SignedTransaction, sendOptions?: any): Promise<TransactionPending>;
|
|
168
|
+
/**
|
|
169
|
+
* Send a transaction and wait for confirmation
|
|
170
|
+
* @param transaction
|
|
171
|
+
* @param opts
|
|
172
|
+
*/
|
|
173
|
+
abstract sendAndConfirm(transaction: SignedTransaction, opts?: any): Promise<TransactionReceipt>;
|
|
174
|
+
/**
|
|
175
|
+
* Sign a buffer (e.g. a message hash)
|
|
176
|
+
*/
|
|
177
|
+
abstract signBuffer(buffer: Uint8Array): Promise<Uint8Array>;
|
|
178
|
+
/**
|
|
179
|
+
* returns the address of the signer
|
|
180
|
+
*/
|
|
181
|
+
abstract getAddress(): Promise<string>;
|
|
182
|
+
/**
|
|
183
|
+
* Native signer object
|
|
184
|
+
*/
|
|
185
|
+
native: unknown;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
export { Block, type BlockTag, BlockWithTransactions, type Finality, type Provider, SignedTransaction, Signer, type TransactionHash, TransactionPending, TransactionReceipt, TransactionRequest, TransactionResponse };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
type NonPromise<T> = T extends Promise<unknown> ? never : T;
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* By declare a unique field `type` in each class, it ensure that the instance of one class can not
|
|
5
|
+
* be assigned to a variable of another class. Furthermore, it also help to distinguish the type of
|
|
6
|
+
* the instance at runtime.
|
|
7
|
+
* By private the constructor, it ensure that the instance of the class can only be created by the
|
|
8
|
+
* static method `from`, and which can enforce the type of the input parameter should not be a promise.
|
|
9
|
+
* Finally, it will be helpful for the compiler to infer the type of the instance and avoid the mistake.
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* TransactionHash represents a transaction hash.
|
|
13
|
+
*/
|
|
14
|
+
type TransactionHash = string | number;
|
|
15
|
+
/**
|
|
16
|
+
* Block represents a block.
|
|
17
|
+
*/
|
|
18
|
+
declare class Block {
|
|
19
|
+
block: unknown;
|
|
20
|
+
readonly type = "Block";
|
|
21
|
+
private constructor();
|
|
22
|
+
static from<T>(raw: NonPromise<T>): Block;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* BlockWithTransactions represents a block with transactions.
|
|
26
|
+
*/
|
|
27
|
+
declare class BlockWithTransactions {
|
|
28
|
+
block: unknown;
|
|
29
|
+
readonly type = "BlockWithTransactions";
|
|
30
|
+
private constructor();
|
|
31
|
+
static from<T>(raw: NonPromise<T>): BlockWithTransactions;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* BlockTag represents a block tag.
|
|
35
|
+
*/
|
|
36
|
+
type BlockTag = string | number;
|
|
37
|
+
/**
|
|
38
|
+
* Finality represents the finality of a block.
|
|
39
|
+
*/
|
|
40
|
+
type Finality = 'confirmed' | 'finalized';
|
|
41
|
+
/**
|
|
42
|
+
* TransactionRequest represents the request of a transaction.
|
|
43
|
+
*/
|
|
44
|
+
declare class TransactionRequest {
|
|
45
|
+
request: unknown;
|
|
46
|
+
readonly type = "TransactionRequest";
|
|
47
|
+
private constructor();
|
|
48
|
+
static from<T>(raw: NonPromise<T>): TransactionRequest;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* TransactionResponse represents the response of a transaction.
|
|
52
|
+
*/
|
|
53
|
+
declare class TransactionResponse {
|
|
54
|
+
response: unknown;
|
|
55
|
+
readonly type = "TransactionResponse";
|
|
56
|
+
private constructor();
|
|
57
|
+
static from<T>(raw: NonPromise<T>): TransactionResponse;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* TransactionReceipt represents the receipt of a transaction.
|
|
61
|
+
*/
|
|
62
|
+
declare class TransactionReceipt {
|
|
63
|
+
receipt: unknown;
|
|
64
|
+
readonly type = "TransactionReceipt";
|
|
65
|
+
private constructor();
|
|
66
|
+
static from<T>(raw: NonPromise<T>): TransactionReceipt;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* SignedTransaction represents a signed transaction.
|
|
70
|
+
*/
|
|
71
|
+
declare class SignedTransaction {
|
|
72
|
+
signed: unknown;
|
|
73
|
+
readonly type = "SignedTransaction";
|
|
74
|
+
private constructor();
|
|
75
|
+
static from<T>(raw: NonPromise<T>): SignedTransaction;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* TransactionPending represents a pending transaction.
|
|
79
|
+
*/
|
|
80
|
+
declare class TransactionPending {
|
|
81
|
+
pending: unknown;
|
|
82
|
+
readonly type = "TransactionPending";
|
|
83
|
+
private constructor();
|
|
84
|
+
static from<T>(raw: NonPromise<T>): TransactionPending;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
interface Provider {
|
|
88
|
+
/**
|
|
89
|
+
* Get the block specified by blockTag
|
|
90
|
+
* @param {BlockTag} [blockTag]
|
|
91
|
+
* @returns
|
|
92
|
+
*/
|
|
93
|
+
getBlock(blockTag: BlockTag): Promise<Block>;
|
|
94
|
+
getBlockWithTransactions(blockTag: BlockTag): Promise<BlockWithTransactions>;
|
|
95
|
+
/**
|
|
96
|
+
* Get information about a transaction
|
|
97
|
+
* @param {string} txHash
|
|
98
|
+
* @returns
|
|
99
|
+
*/
|
|
100
|
+
getTransaction(txHash: string): Promise<TransactionResponse>;
|
|
101
|
+
/**
|
|
102
|
+
* Get the receipt of a transaction
|
|
103
|
+
* @param txHash
|
|
104
|
+
*/
|
|
105
|
+
getTransactionReceipt(txHash: string): Promise<TransactionReceipt>;
|
|
106
|
+
/**
|
|
107
|
+
* Get the current block number
|
|
108
|
+
* @returns Promise<number> the current block number
|
|
109
|
+
*/
|
|
110
|
+
getBlockNumber(): Promise<number>;
|
|
111
|
+
/**
|
|
112
|
+
* Get the current slot number for commitment
|
|
113
|
+
* @param commitment
|
|
114
|
+
*/
|
|
115
|
+
getSlot(commitment?: Finality): Promise<number>;
|
|
116
|
+
/**
|
|
117
|
+
* Get the number of transactions sent from this address
|
|
118
|
+
* @param {string|Promise<string>} addressOrName The address to get the numbers of transactions from
|
|
119
|
+
* @param {BlockTag|Promise<BlockTag>} [blockTag] The block tag to get the numbers of transactions from
|
|
120
|
+
* @returns Promise<number> The number of transactions sent from this address
|
|
121
|
+
*/
|
|
122
|
+
getTransactionCount(addressOrName: string | Promise<string>, blockTag?: BlockTag | Promise<BlockTag>): Promise<number>;
|
|
123
|
+
/**
|
|
124
|
+
* Get the balance of an address
|
|
125
|
+
* @param address
|
|
126
|
+
*/
|
|
127
|
+
getBalance(address: string): Promise<string>;
|
|
128
|
+
/**
|
|
129
|
+
* Gets the UNIX timestamp for the block identified by blockTag. The UNIX timestamp is defined as the count of
|
|
130
|
+
* seconds since the Unix Epoch on January 1st, 1970 at UTC. If blockTag is not provided, the latest block is used.
|
|
131
|
+
* @param {string?} blockTag
|
|
132
|
+
* @returns Promise<number> the UNIX timestamp of the block identified by blockTag
|
|
133
|
+
*/
|
|
134
|
+
getBlockTimestamp(blockTag: BlockTag): Promise<number>;
|
|
135
|
+
/**
|
|
136
|
+
* sendTransaction sends a signed transaction in bytes to the blockchain.
|
|
137
|
+
* @param transaction
|
|
138
|
+
* @param sendOptions
|
|
139
|
+
*/
|
|
140
|
+
sendTransaction(transaction: SignedTransaction, sendOptions?: any): Promise<TransactionPending>;
|
|
141
|
+
/**
|
|
142
|
+
* Send a transaction and wait for confirmation
|
|
143
|
+
* @param transaction
|
|
144
|
+
* @param opts
|
|
145
|
+
*/
|
|
146
|
+
sendAndConfirm(transaction: SignedTransaction, opts?: any): Promise<TransactionReceipt>;
|
|
147
|
+
readonly native: unknown;
|
|
148
|
+
connectedTo<T>(item: T): T;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
declare abstract class Signer {
|
|
152
|
+
/**
|
|
153
|
+
* Connect to a provider
|
|
154
|
+
* @param provider
|
|
155
|
+
*/
|
|
156
|
+
abstract connect(provider: Provider): Signer;
|
|
157
|
+
/**
|
|
158
|
+
* Sign a transaction
|
|
159
|
+
* @param transaction
|
|
160
|
+
*/
|
|
161
|
+
abstract signTransaction(transaction: TransactionRequest): Promise<SignedTransaction>;
|
|
162
|
+
/**
|
|
163
|
+
* Send a transaction
|
|
164
|
+
* @param transaction
|
|
165
|
+
* @param sendOptions
|
|
166
|
+
*/
|
|
167
|
+
abstract sendTransaction(transaction: SignedTransaction, sendOptions?: any): Promise<TransactionPending>;
|
|
168
|
+
/**
|
|
169
|
+
* Send a transaction and wait for confirmation
|
|
170
|
+
* @param transaction
|
|
171
|
+
* @param opts
|
|
172
|
+
*/
|
|
173
|
+
abstract sendAndConfirm(transaction: SignedTransaction, opts?: any): Promise<TransactionReceipt>;
|
|
174
|
+
/**
|
|
175
|
+
* Sign a buffer (e.g. a message hash)
|
|
176
|
+
*/
|
|
177
|
+
abstract signBuffer(buffer: Uint8Array): Promise<Uint8Array>;
|
|
178
|
+
/**
|
|
179
|
+
* returns the address of the signer
|
|
180
|
+
*/
|
|
181
|
+
abstract getAddress(): Promise<string>;
|
|
182
|
+
/**
|
|
183
|
+
* Native signer object
|
|
184
|
+
*/
|
|
185
|
+
native: unknown;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
export { Block, type BlockTag, BlockWithTransactions, type Finality, type Provider, SignedTransaction, Signer, type TransactionHash, TransactionPending, TransactionReceipt, TransactionRequest, TransactionResponse };
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
// src/transaction.ts
|
|
2
|
+
var Block = class _Block {
|
|
3
|
+
constructor(block) {
|
|
4
|
+
this.block = block;
|
|
5
|
+
this.type = "Block";
|
|
6
|
+
}
|
|
7
|
+
static from(raw) {
|
|
8
|
+
return new _Block(raw);
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
var BlockWithTransactions = class _BlockWithTransactions {
|
|
12
|
+
constructor(block) {
|
|
13
|
+
this.block = block;
|
|
14
|
+
this.type = "BlockWithTransactions";
|
|
15
|
+
}
|
|
16
|
+
static from(raw) {
|
|
17
|
+
return new _BlockWithTransactions(raw);
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
var TransactionRequest = class _TransactionRequest {
|
|
21
|
+
constructor(request) {
|
|
22
|
+
this.request = request;
|
|
23
|
+
this.type = "TransactionRequest";
|
|
24
|
+
}
|
|
25
|
+
static from(raw) {
|
|
26
|
+
return new _TransactionRequest(raw);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
var TransactionResponse = class _TransactionResponse {
|
|
30
|
+
constructor(response) {
|
|
31
|
+
this.response = response;
|
|
32
|
+
this.type = "TransactionResponse";
|
|
33
|
+
}
|
|
34
|
+
static from(raw) {
|
|
35
|
+
return new _TransactionResponse(raw);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
var TransactionReceipt = class _TransactionReceipt {
|
|
39
|
+
constructor(receipt) {
|
|
40
|
+
this.receipt = receipt;
|
|
41
|
+
this.type = "TransactionReceipt";
|
|
42
|
+
}
|
|
43
|
+
static from(raw) {
|
|
44
|
+
return new _TransactionReceipt(raw);
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
var SignedTransaction = class _SignedTransaction {
|
|
48
|
+
constructor(signed) {
|
|
49
|
+
this.signed = signed;
|
|
50
|
+
this.type = "SignedTransaction";
|
|
51
|
+
}
|
|
52
|
+
static from(raw) {
|
|
53
|
+
return new _SignedTransaction(raw);
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
var TransactionPending = class _TransactionPending {
|
|
57
|
+
constructor(pending) {
|
|
58
|
+
this.pending = pending;
|
|
59
|
+
this.type = "TransactionPending";
|
|
60
|
+
}
|
|
61
|
+
static from(raw) {
|
|
62
|
+
return new _TransactionPending(raw);
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
// src/signer.ts
|
|
67
|
+
var Signer = class {
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export { Block, BlockWithTransactions, SignedTransaction, Signer, TransactionPending, TransactionReceipt, TransactionRequest, TransactionResponse };
|
|
71
|
+
//# sourceMappingURL=out.js.map
|
|
72
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/transaction.ts","../src/signer.ts"],"names":[],"mappings":";AAmBO,IAAM,QAAN,MAAM,OAAM;AAAA,EAEP,YAAmB,OAAgB;AAAhB;AAD3B,SAAS,OAAO;AAAA,EAC4B;AAAA,EAC5C,OAAO,KAAQ,KAA2B;AACtC,WAAO,IAAI,OAAM,GAAG;AAAA,EACxB;AACJ;AAKO,IAAM,wBAAN,MAAM,uBAAsB;AAAA,EAEvB,YAAmB,OAAgB;AAAhB;AAD3B,SAAS,OAAO;AAAA,EAC4B;AAAA,EAC5C,OAAO,KAAQ,KAA2C;AACtD,WAAO,IAAI,uBAAsB,GAAG;AAAA,EACxC;AACJ;AAeO,IAAM,qBAAN,MAAM,oBAAmB;AAAA,EAEpB,YAAmB,SAAkB;AAAlB;AAD3B,SAAS,OAAO;AAAA,EAC8B;AAAA,EAC9C,OAAO,KAAQ,KAAwC;AACnD,WAAO,IAAI,oBAAmB,GAAG;AAAA,EACrC;AACJ;AAKO,IAAM,sBAAN,MAAM,qBAAoB;AAAA,EAErB,YAAmB,UAAmB;AAAnB;AAD3B,SAAS,OAAO;AAAA,EAC+B;AAAA,EAC/C,OAAO,KAAQ,KAAyC;AACpD,WAAO,IAAI,qBAAoB,GAAG;AAAA,EACtC;AACJ;AAKO,IAAM,qBAAN,MAAM,oBAAmB;AAAA,EAEpB,YAAmB,SAAkB;AAAlB;AAD3B,SAAS,OAAO;AAAA,EAC8B;AAAA,EAC9C,OAAO,KAAQ,KAAwC;AACnD,WAAO,IAAI,oBAAmB,GAAG;AAAA,EACrC;AACJ;AAKO,IAAM,oBAAN,MAAM,mBAAkB;AAAA,EAEnB,YAAmB,QAAiB;AAAjB;AAD3B,SAAS,OAAO;AAAA,EAC6B;AAAA,EAC7C,OAAO,KAAQ,KAAuC;AAClD,WAAO,IAAI,mBAAkB,GAAG;AAAA,EACpC;AACJ;AAKO,IAAM,qBAAN,MAAM,oBAAmB;AAAA,EAEpB,YAAmB,SAAkB;AAAlB;AAD3B,SAAS,OAAO;AAAA,EAC8B;AAAA,EAC9C,OAAO,KAAQ,KAAwC;AACnD,WAAO,IAAI,oBAAmB,GAAG;AAAA,EACrC;AACJ;;;AClGO,IAAe,SAAf,MAAsB;AAyC7B","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 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 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 * TransactionRequest represents the request of a transaction.\n */\nexport class TransactionRequest {\n readonly type = 'TransactionRequest'\n private constructor(public request: unknown) {}\n static from<T>(raw: NonPromise<T>): 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 static from<T>(raw: NonPromise<T>): 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 static from<T>(raw: NonPromise<T>): 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 static from<T>(raw: NonPromise<T>): 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 static from<T>(raw: NonPromise<T>): TransactionPending {\n return new TransactionPending(raw)\n }\n}\n","import { Provider } from './provider'\nimport { SignedTransaction, TransactionPending, TransactionReceipt, TransactionRequest } from './transaction'\n\nexport abstract class Signer {\n /**\n * Connect to a provider\n * @param provider\n */\n abstract connect(provider: Provider): Signer\n\n /**\n * Sign a transaction\n * @param transaction\n */\n abstract signTransaction(transaction: TransactionRequest): Promise<SignedTransaction>\n\n /**\n * Send a transaction\n * @param transaction\n * @param sendOptions\n */\n abstract sendTransaction(transaction: SignedTransaction, sendOptions?: any): Promise<TransactionPending>\n\n /**\n * Send a transaction and wait for confirmation\n * @param transaction\n * @param opts\n */\n abstract sendAndConfirm(transaction: SignedTransaction, opts?: any): Promise<TransactionReceipt>\n\n /**\n * Sign a buffer (e.g. a message hash)\n */\n abstract signBuffer(buffer: Uint8Array): Promise<Uint8Array>\n\n /**\n * returns the address of the signer\n */\n abstract getAddress(): Promise<string>\n\n /**\n * Native signer object\n */\n native: unknown\n}\n"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@layerzerolabs/lz-core",
|
|
3
|
+
"version": "2.1.23",
|
|
4
|
+
"description": "LayerZero Core Library",
|
|
5
|
+
"license": "BUSL-1.1",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"import": "./dist/index.mjs",
|
|
10
|
+
"require": "./dist/index.cjs"
|
|
11
|
+
},
|
|
12
|
+
"./package.json": "./package.json"
|
|
13
|
+
},
|
|
14
|
+
"main": "./dist/index.cjs",
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"files": [
|
|
17
|
+
"dist/**/*"
|
|
18
|
+
],
|
|
19
|
+
"scripts": {
|
|
20
|
+
"build": "$npm_execpath clean-prebuild && $npm_execpath build-ts",
|
|
21
|
+
"build-ts": "$npm_execpath tsc --noEmit && $npm_execpath tsup",
|
|
22
|
+
"clean": "$npm_execpath clean-prebuild && rimraf .turbo",
|
|
23
|
+
"clean-prebuild": "rimraf dist"
|
|
24
|
+
},
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"tiny-invariant": "^1.3.1"
|
|
27
|
+
},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"@jest/globals": "^29.7.0",
|
|
30
|
+
"@layerzerolabs/tsup-config-next": "^2.1.23",
|
|
31
|
+
"@layerzerolabs/typescript-config-next": "^2.1.23",
|
|
32
|
+
"@types/jest": "^29.5.10",
|
|
33
|
+
"jest": "^29.7.0",
|
|
34
|
+
"rimraf": "^5.0.5",
|
|
35
|
+
"ts-jest": "^29.1.1",
|
|
36
|
+
"tsup": "^8.0.1",
|
|
37
|
+
"typescript": "~5.2.2"
|
|
38
|
+
},
|
|
39
|
+
"publishConfig": {
|
|
40
|
+
"access": "public"
|
|
41
|
+
}
|
|
42
|
+
}
|