@mainsail/evm 0.0.1-evm.9 → 0.0.1-rc.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/index.d.ts +137 -18
  2. package/index.js +2 -1
  3. package/package.json +8 -7
package/index.d.ts CHANGED
@@ -3,24 +3,58 @@
3
3
 
4
4
  /* auto-generated by NAPI-RS */
5
5
 
6
+ export interface JsEvmOptions {
7
+ path: string
8
+ logger?: (...args: any[]) => any
9
+ historySize?: bigint
10
+ }
6
11
  export interface JsTransactionContext {
7
- caller: string
12
+ from: string
13
+ legacyAddress?: string
8
14
  /** Omit recipient when deploying a contract */
9
- recipient?: string
15
+ to?: string
10
16
  gasLimit: bigint
11
- gasPrice?: bigint
17
+ gasPrice: bigint
12
18
  value: bigint
13
19
  nonce: bigint
14
20
  data: Buffer
15
21
  txHash: string
22
+ index?: number
23
+ blockContext: JsBlockContext
24
+ specId: string
25
+ }
26
+ export interface JsTransactionSimulateContext {
27
+ from: string
28
+ /** Omit recipient when deploying a contract */
29
+ to?: string
30
+ gasLimit: bigint
31
+ gasPrice: bigint
32
+ value: bigint
33
+ nonce: bigint
34
+ data: Buffer
16
35
  blockContext: JsBlockContext
17
36
  specId: string
18
37
  }
38
+ export interface JsPreverifyTransactionContext {
39
+ from: string
40
+ legacyAddress?: string
41
+ /** Omit recipient when deploying a contract */
42
+ to?: string
43
+ gasLimit: bigint
44
+ gasPrice: bigint
45
+ value: bigint
46
+ nonce: bigint
47
+ data: Buffer
48
+ txHash: string
49
+ specId: string
50
+ blockGasLimit: bigint
51
+ }
19
52
  export interface JsTransactionViewContext {
20
- caller: string
21
- recipient: string
53
+ from: string
54
+ to: string
22
55
  data: Buffer
23
56
  specId: string
57
+ gasLimit?: bigint
24
58
  }
25
59
  export interface JsBlockContext {
26
60
  commitKey: JsCommitKey
@@ -32,12 +66,14 @@ export interface JsGenesisContext {
32
66
  account: string
33
67
  deployerAccount: string
34
68
  validatorContract: string
69
+ usernameContract: string
70
+ initialBlockNumber: bigint
35
71
  initialSupply: bigint
36
72
  }
37
- export interface JsCalculateActiveValidatorsContext {
73
+ export interface JsCalculateRoundValidatorsContext {
38
74
  commitKey: JsCommitKey
39
75
  timestamp: bigint
40
- activeValidators: bigint
76
+ roundValidators: bigint
41
77
  validatorAddress: string
42
78
  specId: string
43
79
  }
@@ -49,15 +85,36 @@ export interface JsUpdateRewardsAndVotesContext {
49
85
  specId: string
50
86
  }
51
87
  export interface JsCommitKey {
52
- height: bigint
88
+ blockNumber: bigint
53
89
  round: bigint
90
+ blockHash?: string
91
+ }
92
+ export interface JsCommitData {
93
+ commitRound: bigint
94
+ blockHash: string
95
+ block: Buffer
96
+ proof: Buffer
97
+ transactionHashes: Array<string>
98
+ transactions: Array<Buffer>
54
99
  }
55
100
  export interface JsPrepareNextCommitContext {
56
101
  commitKey: JsCommitKey
57
102
  }
103
+ export const enum LogLevel {
104
+ Info = 0,
105
+ Debug = 1,
106
+ Notice = 2,
107
+ Emergency = 3,
108
+ Alert = 4,
109
+ Critical = 5,
110
+ Warning = 6
111
+ }
58
112
  export interface JsProcessResult {
59
113
  receipt: JsTransactionReceipt
60
114
  }
115
+ export interface JsSimulateResult {
116
+ receipt: JsTransactionReceipt
117
+ }
61
118
  export interface JsCommitResult {
62
119
  dirtyAccounts: Array<JsAccountUpdate>
63
120
  }
@@ -65,13 +122,18 @@ export interface JsViewResult {
65
122
  success: boolean
66
123
  output?: Buffer
67
124
  }
125
+ export interface JsPreverifyTransactionResult {
126
+ success: boolean
127
+ initialGasUsed: bigint
128
+ error?: string
129
+ }
68
130
  export interface JsTransactionReceipt {
69
- blockHeight?: bigint
131
+ blockNumber?: bigint
70
132
  txHash?: string
71
133
  gasUsed: bigint
72
134
  gasRefunded: bigint
73
- success: boolean
74
- deployedContractAddress?: string
135
+ status: number
136
+ contractAddress?: string
75
137
  logs: any
76
138
  output?: Buffer
77
139
  }
@@ -85,29 +147,86 @@ export interface JsAccountUpdate {
85
147
  nonce: bigint
86
148
  vote?: string
87
149
  unvote?: string
150
+ username?: string
151
+ usernameResigned: boolean
152
+ legacyMergeInfo?: JsAccountMergeInfo
153
+ }
154
+ export interface JsAccountInfoExtended {
155
+ address: string
156
+ balance: bigint
157
+ nonce: bigint
158
+ legacyAttributes: JsLegacyAttributes
159
+ }
160
+ export interface JsLegacyColdWallet {
161
+ address: string
162
+ balance: bigint
163
+ legacyAttributes: JsLegacyAttributes
164
+ mergeInfo?: JsAccountMergeInfo
165
+ }
166
+ export interface JsAccountMergeInfo {
167
+ address: string
168
+ txHash: string
169
+ }
170
+ export interface JsLegacyAttributes {
171
+ secondPublicKey?: string
172
+ multiSignature?: JsLegacyMultiSignatureAttribute
173
+ }
174
+ export interface JsLegacyMultiSignatureAttribute {
175
+ min: number
176
+ publicKeys: Array<string>
88
177
  }
89
178
  export interface JsGetAccounts {
90
179
  nextOffset?: bigint
91
- accounts: Array<JsAccountUpdate>
180
+ accounts: Array<JsAccountInfoExtended>
181
+ }
182
+ export interface JsGetLegacyColdWallets {
183
+ nextOffset?: bigint
184
+ wallets: Array<JsLegacyColdWallet>
92
185
  }
93
186
  export interface JsGetReceipts {
94
187
  nextOffset?: bigint
95
188
  receipts: Array<JsTransactionReceipt>
96
189
  }
190
+ export interface JsGetReceipt {
191
+ receipt?: JsTransactionReceipt
192
+ }
193
+ export interface JsGetState {
194
+ blockNumber: bigint
195
+ totalRound: bigint
196
+ }
97
197
  export type JsEvmWrapper = Evm
98
198
  export declare class Evm {
99
- constructor(path: string)
199
+ constructor(opts: JsEvmOptions)
200
+ preverifyTransaction(txCtx: JsPreverifyTransactionContext): Promise<JsPreverifyTransactionResult>
100
201
  view(viewCtx: JsTransactionViewContext): Promise<JsViewResult>
101
202
  process(txCtx: JsTransactionContext): Promise<JsProcessResult>
203
+ simulate(txCtx: JsTransactionSimulateContext): Promise<JsSimulateResult>
102
204
  initializeGenesis(genesisCtx: JsGenesisContext): Promise<void>
103
205
  prepareNextCommit(ctx: JsPrepareNextCommitContext): Promise<void>
104
- calculateActiveValidators(ctx: JsCalculateActiveValidatorsContext): Promise<void>
206
+ calculateRoundValidators(ctx: JsCalculateRoundValidatorsContext): Promise<void>
105
207
  updateRewardsAndVotes(ctx: JsUpdateRewardsAndVotesContext): Promise<void>
106
- getAccountInfo(address: string): Promise<JsAccountInfo>
208
+ getAccountInfo(address: string, blockNumber?: bigint | undefined | null): Promise<JsAccountInfo>
209
+ getAccountInfoExtended(address: string, legacyAddress?: string | undefined | null): Promise<JsAccountInfoExtended>
210
+ importAccountInfos(infos: Array<JsAccountInfoExtended>): Promise<void>
211
+ importLegacyColdWallets(infos: Array<JsLegacyColdWallet>): Promise<void>
107
212
  getAccounts(offset: bigint, limit: bigint): Promise<JsGetAccounts>
213
+ getLegacyAttributes(address: string, legacyAddress?: string | undefined | null): Promise<JsLegacyAttributes | null>
214
+ getLegacyColdWallets(offset: bigint, limit: bigint): Promise<JsGetLegacyColdWallets>
108
215
  getReceipts(offset: bigint, limit: bigint): Promise<JsGetReceipts>
109
- codeAt(address: string): Promise<string>
216
+ getReceipt(blockNumber: bigint, txHash: string): Promise<JsGetReceipt>
217
+ codeAt(address: string, blockNumber?: bigint | undefined | null): Promise<string>
110
218
  storageAt(address: string, slot: bigint): Promise<string>
111
- commit(commitKey: JsCommitKey): Promise<JsCommitResult>
112
- stateHash(commitKey: JsCommitKey, currentHash: string): Promise<string>
219
+ commit(commitKey: JsCommitKey, commitData?: JsCommitData | undefined | null): Promise<JsCommitResult>
220
+ stateRoot(commitKey: JsCommitKey, currentHash: string): Promise<string>
221
+ logsBloom(commitKey: JsCommitKey): Promise<string>
222
+ isEmpty(): Promise<boolean>
223
+ getState(): Promise<JsGetState>
224
+ getBlockHeaderBytes(blockNumber: bigint): Promise<Buffer | undefined>
225
+ getBlockNumberByHash(blockHash: string): Promise<bigint | undefined>
226
+ getProofBytes(blockNumber: bigint): Promise<Buffer | undefined>
227
+ getTransactionBytes(key: string): Promise<Buffer | undefined>
228
+ getTransactionKeyByHash(txHash: string): Promise<string | undefined>
229
+ snapshot(commitKey: JsCommitKey): Promise<void>
230
+ rollback(commitKey: JsCommitKey): Promise<void>
231
+ dispose(): Promise<void>
113
232
  }
package/index.js CHANGED
@@ -310,6 +310,7 @@ if (!nativeBinding) {
310
310
  throw new Error(`Failed to load native binding`)
311
311
  }
312
312
 
313
- const { Evm } = nativeBinding
313
+ const { LogLevel, Evm } = nativeBinding
314
314
 
315
+ module.exports.LogLevel = LogLevel
315
316
  module.exports.Evm = Evm
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@mainsail/evm",
3
- "version": "0.0.1-evm.9",
3
+ "version": "0.0.1-rc.2",
4
4
  "description": "EVM for the Mainsail blockchain",
5
5
  "license": "GPL-3.0-only",
6
6
  "contributors": [],
7
7
  "main": "index.js",
8
8
  "types": "index.d.ts",
9
9
  "devDependencies": {
10
- "@napi-rs/cli": "^2.18.4"
10
+ "@napi-rs/cli": "2.18.4"
11
11
  },
12
12
  "engines": {
13
13
  "node": ">=20.x"
@@ -25,10 +25,10 @@
25
25
  }
26
26
  },
27
27
  "optionalDependencies": {
28
- "@mainsail/evm-linux-arm64-gnu": "0.0.1-evm.9",
29
- "@mainsail/evm-linux-arm64-musl": "0.0.1-evm.9",
30
- "@mainsail/evm-linux-x64-gnu": "0.0.1-evm.9",
31
- "@mainsail/evm-linux-x64-musl": "0.0.1-evm.9"
28
+ "@mainsail/evm-linux-arm64-gnu": "0.0.1-rc.2",
29
+ "@mainsail/evm-linux-arm64-musl": "0.0.1-rc.2",
30
+ "@mainsail/evm-linux-x64-gnu": "0.0.1-rc.2",
31
+ "@mainsail/evm-linux-x64-musl": "0.0.1-rc.2"
32
32
  },
33
33
  "scripts": {
34
34
  "artifacts": "napi artifacts",
@@ -38,6 +38,7 @@
38
38
  "clean": "del index.js index.d.ts evm.*.node target",
39
39
  "release": "pnpm publish --access public",
40
40
  "test": "cargo test --release",
41
- "version": "napi version "
41
+ "test:coverage": "mkdir -p coverage && cargo llvm-cov --lcov --output-path coverage/lcov.info --remap-path-prefix",
42
+ "version": "napi version"
42
43
  }
43
44
  }