@mainsail/evm 0.0.1-evm.2 → 0.0.1-evm.21

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 +178 -17
  2. package/index.js +2 -1
  3. package/package.json +7 -6
package/index.d.ts CHANGED
@@ -3,21 +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
17
+ gasPrice: bigint
18
+ value: bigint
19
+ nonce: bigint
11
20
  data: Buffer
12
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
13
35
  blockContext: JsBlockContext
14
36
  specId: string
15
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
+ }
16
52
  export interface JsTransactionViewContext {
17
- caller: string
18
- recipient: string
53
+ from: string
54
+ to: string
19
55
  data: Buffer
20
56
  specId: string
57
+ gasLimit?: bigint
21
58
  }
22
59
  export interface JsBlockContext {
23
60
  commitKey: JsCommitKey
@@ -25,30 +62,77 @@ export interface JsBlockContext {
25
62
  timestamp: bigint
26
63
  validatorAddress: string
27
64
  }
28
- export interface JsAccountUpdateContext {
29
- commitKey: JsCommitKey
65
+ export interface JsGenesisContext {
30
66
  account: string
31
- nonce: bigint
67
+ deployerAccount: string
68
+ validatorContract: string
69
+ usernameContract: string
70
+ initialBlockNumber: bigint
71
+ initialSupply: bigint
72
+ }
73
+ export interface JsCalculateRoundValidatorsContext {
74
+ commitKey: JsCommitKey
75
+ timestamp: bigint
76
+ roundValidators: bigint
77
+ validatorAddress: string
78
+ specId: string
79
+ }
80
+ export interface JsUpdateRewardsAndVotesContext {
81
+ commitKey: JsCommitKey
82
+ timestamp: bigint
83
+ blockReward: bigint
84
+ validatorAddress: string
85
+ specId: string
32
86
  }
33
87
  export interface JsCommitKey {
34
- height: bigint
88
+ blockNumber: bigint
35
89
  round: bigint
90
+ blockHash?: string
91
+ }
92
+ export interface JsCommitData {
93
+ blockHash: string
94
+ block: Buffer
95
+ proof: Buffer
96
+ transactionHashes: Array<string>
97
+ transactions: Array<Buffer>
98
+ }
99
+ export interface JsPrepareNextCommitContext {
100
+ commitKey: JsCommitKey
101
+ }
102
+ export const enum LogLevel {
103
+ Info = 0,
104
+ Debug = 1,
105
+ Notice = 2,
106
+ Emergency = 3,
107
+ Alert = 4,
108
+ Critical = 5,
109
+ Warning = 6
36
110
  }
37
111
  export interface JsProcessResult {
38
112
  receipt: JsTransactionReceipt
39
113
  }
114
+ export interface JsSimulateResult {
115
+ receipt: JsTransactionReceipt
116
+ }
40
117
  export interface JsCommitResult {
41
-
118
+ dirtyAccounts: Array<JsAccountUpdate>
42
119
  }
43
120
  export interface JsViewResult {
44
121
  success: boolean
45
122
  output?: Buffer
46
123
  }
124
+ export interface JsPreverifyTransactionResult {
125
+ success: boolean
126
+ initialGasUsed: bigint
127
+ error?: string
128
+ }
47
129
  export interface JsTransactionReceipt {
130
+ blockNumber?: bigint
131
+ txHash?: string
48
132
  gasUsed: bigint
49
133
  gasRefunded: bigint
50
- success: boolean
51
- deployedContractAddress?: string
134
+ status: number
135
+ contractAddress?: string
52
136
  logs: any
53
137
  output?: Buffer
54
138
  }
@@ -56,15 +140,92 @@ export interface JsAccountInfo {
56
140
  balance: bigint
57
141
  nonce: bigint
58
142
  }
143
+ export interface JsAccountUpdate {
144
+ address: string
145
+ balance: bigint
146
+ nonce: bigint
147
+ vote?: string
148
+ unvote?: string
149
+ username?: string
150
+ usernameResigned: boolean
151
+ legacyMergeInfo?: JsAccountMergeInfo
152
+ }
153
+ export interface JsAccountInfoExtended {
154
+ address: string
155
+ balance: bigint
156
+ nonce: bigint
157
+ legacyAttributes: JsLegacyAttributes
158
+ }
159
+ export interface JsLegacyColdWallet {
160
+ address: string
161
+ balance: bigint
162
+ legacyAttributes: JsLegacyAttributes
163
+ mergeInfo?: JsAccountMergeInfo
164
+ }
165
+ export interface JsAccountMergeInfo {
166
+ address: string
167
+ txHash: string
168
+ }
169
+ export interface JsLegacyAttributes {
170
+ secondPublicKey?: string
171
+ multiSignature?: JsLegacyMultiSignatureAttribute
172
+ }
173
+ export interface JsLegacyMultiSignatureAttribute {
174
+ min: number
175
+ publicKeys: Array<string>
176
+ }
177
+ export interface JsGetAccounts {
178
+ nextOffset?: bigint
179
+ accounts: Array<JsAccountInfoExtended>
180
+ }
181
+ export interface JsGetLegacyColdWallets {
182
+ nextOffset?: bigint
183
+ wallets: Array<JsLegacyColdWallet>
184
+ }
185
+ export interface JsGetReceipts {
186
+ nextOffset?: bigint
187
+ receipts: Array<JsTransactionReceipt>
188
+ }
189
+ export interface JsGetReceipt {
190
+ receipt?: JsTransactionReceipt
191
+ }
192
+ export interface JsGetState {
193
+ blockNumber: bigint
194
+ totalRound: bigint
195
+ }
59
196
  export type JsEvmWrapper = Evm
60
197
  export declare class Evm {
61
- constructor(path: string)
198
+ constructor(opts: JsEvmOptions)
199
+ preverifyTransaction(txCtx: JsPreverifyTransactionContext): Promise<JsPreverifyTransactionResult>
62
200
  view(viewCtx: JsTransactionViewContext): Promise<JsViewResult>
63
201
  process(txCtx: JsTransactionContext): Promise<JsProcessResult>
64
- updateAccountInfo(accountUpdateCtx: JsAccountUpdateContext): Promise<void>
65
- getAccountInfo(address: string): Promise<JsAccountInfo>
66
- codeAt(address: string): Promise<string>
202
+ simulate(txCtx: JsTransactionSimulateContext): Promise<JsSimulateResult>
203
+ initializeGenesis(genesisCtx: JsGenesisContext): Promise<void>
204
+ prepareNextCommit(ctx: JsPrepareNextCommitContext): Promise<void>
205
+ calculateRoundValidators(ctx: JsCalculateRoundValidatorsContext): Promise<void>
206
+ updateRewardsAndVotes(ctx: JsUpdateRewardsAndVotesContext): Promise<void>
207
+ getAccountInfo(address: string, blockNumber?: bigint | undefined | null): Promise<JsAccountInfo>
208
+ getAccountInfoExtended(address: string, legacyAddress?: string | undefined | null): Promise<JsAccountInfoExtended>
209
+ importAccountInfos(infos: Array<JsAccountInfoExtended>): Promise<void>
210
+ importLegacyColdWallets(infos: Array<JsLegacyColdWallet>): Promise<void>
211
+ getAccounts(offset: bigint, limit: bigint): Promise<JsGetAccounts>
212
+ getLegacyAttributes(address: string, legacyAddress?: string | undefined | null): Promise<JsLegacyAttributes | null>
213
+ getLegacyColdWallets(offset: bigint, limit: bigint): Promise<JsGetLegacyColdWallets>
214
+ getReceipts(offset: bigint, limit: bigint): Promise<JsGetReceipts>
215
+ getReceipt(blockNumber: bigint, txHash: string): Promise<JsGetReceipt>
216
+ codeAt(address: string, blockNumber?: bigint | undefined | null): Promise<string>
67
217
  storageAt(address: string, slot: bigint): Promise<string>
68
- commit(commitKey: JsCommitKey): Promise<JsCommitResult>
69
- stateHash(commitKey: JsCommitKey, currentHash: string): Promise<string>
218
+ commit(commitKey: JsCommitKey, commitData?: JsCommitData | undefined | null): Promise<JsCommitResult>
219
+ stateRoot(commitKey: JsCommitKey, currentHash: string): Promise<string>
220
+ logsBloom(commitKey: JsCommitKey): Promise<string>
221
+ isEmpty(): Promise<boolean>
222
+ getState(): Promise<JsGetState>
223
+ getBlockHeaderBytes(blockNumber: bigint): Promise<Buffer | undefined>
224
+ getBlockNumberByHash(blockHash: string): Promise<bigint | undefined>
225
+ getProofBytes(blockNumber: bigint): Promise<Buffer | undefined>
226
+ getTransactionBytes(key: string): Promise<Buffer | undefined>
227
+ getTransactionKeyByHash(txHash: string): Promise<string | undefined>
228
+ snapshot(commitKey: JsCommitKey): Promise<void>
229
+ rollback(commitKey: JsCommitKey): Promise<void>
230
+ dispose(): Promise<void>
70
231
  }
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.2",
3
+ "version": "0.0.1-evm.21",
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.2",
29
- "@mainsail/evm-linux-arm64-musl": "0.0.1-evm.2",
30
- "@mainsail/evm-linux-x64-gnu": "0.0.1-evm.2",
31
- "@mainsail/evm-linux-x64-musl": "0.0.1-evm.2"
28
+ "@mainsail/evm-linux-arm64-gnu": "0.0.1-evm.21",
29
+ "@mainsail/evm-linux-arm64-musl": "0.0.1-evm.21",
30
+ "@mainsail/evm-linux-x64-gnu": "0.0.1-evm.21",
31
+ "@mainsail/evm-linux-x64-musl": "0.0.1-evm.21"
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
+ "test:coverage": "mkdir -p coverage && cargo llvm-cov --lcov --output-path coverage/lcov.info --remap-path-prefix",
41
42
  "version": "napi version "
42
43
  }
43
44
  }