@alephium/web3 3.0.0-test.5 → 3.0.0-test.7

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.
@@ -1 +1 @@
1
- {"version":3,"file":"sign.js","sourceRoot":"","sources":["../../../src/utils/sign.ts"],"names":[],"mappings":"AAkBA,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAErF,OAAO,KAAK,IAAI,MAAM,kBAAkB,CAAA;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAA;AAC7C,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAA;AAEzC,IAAI,CAAC,KAAK,CAAC,UAAU,GAAG,CAAC,GAAG,QAAsB,EAAc,EAAE;IAChE,MAAM,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAA;IACzB,KAAK,MAAM,OAAO,IAAI,QAAQ;QAAE,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;IACjD,OAAO,CAAC,CAAC,MAAM,EAAE,CAAA;AACnB,CAAC,CAAA;AAED,IAAI,CAAC,KAAK,CAAC,cAAc,GAAG,CAAC,GAAe,EAAE,GAAG,QAAsB,EAAc,EAAE;IACrF,MAAM,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAClC,KAAK,MAAM,OAAO,IAAI,QAAQ;QAAE,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;IACjD,OAAO,CAAC,CAAC,MAAM,EAAE,CAAA;AACnB,CAAC,CAAA;AAED,SAAS,YAAY,CAAC,OAAgB;IACpC,IAAI,OAAO,KAAK,SAAS,IAAI,OAAO,KAAK,gBAAgB,IAAI,OAAO,KAAK,cAAc,EAAE,CAAC;QACxF,MAAM,IAAI,KAAK,CAAC,oBAAoB,OAAO,+CAA+C,CAAC,CAAA;IAC7F,CAAC;AACH,CAAC;AA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AG,GAAG,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,SAAS,CAAC,CAAA;YACjD,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE,cAAc,CAAC,IAAI,CAAC,EAAE,cAAc,CAAC,SAAS,CAAC,CAAC,CAAA;QAC1E,CAAC;aAAM,CAAC;YACN,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,cAAc,CAAC,SAAS,CAAC,EAAE,cAAc,CAAC,IAAI,CAAC,EAAE,cAAc,CAAC,SAAS,CAAC,CAAC,CAAA;QAC5G,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,KAAK,CAAA;IACd,CAAC;AACH,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alephium/web3",
3
- "version": "3.0.0-test.5",
3
+ "version": "3.0.0-test.7",
4
4
  "description": "A JS/TS library to interact with the Alephium platform",
5
5
  "license": "GPL",
6
6
  "type": "commonjs",
@@ -60,13 +60,13 @@
60
60
  },
61
61
  "author": "Alephium dev <dev@alephium.org>",
62
62
  "config": {
63
- "alephium_version": "4.2.5",
63
+ "alephium_version": "4.4.1",
64
64
  "explorer_backend_version": "3.3.2"
65
65
  },
66
66
  "dependencies": {
67
- "@noble/curves": "1.6.0",
68
- "@noble/hashes": "1.6.1",
69
- "@noble/secp256k1": "1.7.1",
67
+ "@noble/curves": "1.9.7",
68
+ "@noble/hashes": "1.8.0",
69
+ "@noble/secp256k1": "1.7.2",
70
70
  "base-x": "4.0.0",
71
71
  "bignumber.js": "^9.1.1",
72
72
  "eventemitter3": "^4.0.7"
@@ -74,33 +74,21 @@
74
74
  "devDependencies": {
75
75
  "@arethetypeswrong/cli": "^0.18.2",
76
76
  "@babel/eslint-parser": "^7.21.3",
77
- "@size-limit/esbuild": "^11.0.0",
78
- "@size-limit/file": "^11.0.0",
79
77
  "@types/find-up": "^2.1.1",
80
78
  "@types/fs-extra": "^9.0.13",
81
- "@types/jest": "^27.5.2",
82
- "@types/mock-fs": "^4.13.1",
83
79
  "@types/node": "^20.0.0",
84
- "@types/rewire": "^2.5.28",
85
80
  "@typescript-eslint/eslint-plugin": "^5.57.0",
86
81
  "@typescript-eslint/parser": "^5.57.0",
87
82
  "eslint": "^8.37.0",
88
83
  "eslint-config-prettier": "^8.8.0",
89
84
  "eslint-plugin-prettier": "^4.2.1",
90
85
  "eslint-plugin-security": "1.6.0",
91
- "jest": "^28.1.3",
92
- "jest-localstorage-mock": "^2.4.26",
93
- "jest-websocket-mock": "^2.4.0",
94
- "mock-fs": "^5.2.0",
95
- "mock-socket": "^9.2.1",
96
86
  "prettier": "^2.8.7",
97
87
  "process": "^0.11.10",
98
88
  "publint": "^0.3.18",
99
- "rewire": "^6.0.0",
100
89
  "shelljs": "^0.8.5",
101
90
  "size-limit": "^11.0.0",
102
91
  "swagger-typescript-api": "12.0.3",
103
- "ts-jest": "^28.0.8",
104
92
  "ts-node": "^10.9.1",
105
93
  "tsc-alias": "^1.8.16",
106
94
  "tslib": "^2.5.0",
@@ -111,12 +99,13 @@
111
99
  "npm": ">=7.0.0"
112
100
  },
113
101
  "scripts": {
114
- "clean": "rm -rf node_modules dist",
115
- "build": "rm -rf dist && pnpm build:cjs && pnpm build:esm",
102
+ "build": "pnpm clean && pnpm build:cjs && pnpm build:esm",
116
103
  "build:cjs": "tsc --project tsconfig.build.json --module commonjs --moduleResolution node --outDir dist/_cjs --declaration --verbatimModuleSyntax false && printf '{\"type\":\"commonjs\"}' > dist/_cjs/package.json",
117
104
  "build:esm": "tsc --project tsconfig.build.json --outDir dist/_esm --declaration && tsc-alias --project tsconfig.build.json --outDir dist/_esm --resolve-full-paths && printf '{\"type\":\"module\",\"sideEffects\":false}' > dist/_esm/package.json",
105
+ "clean": "rm -rf dist",
106
+ "clean:all": "pnpm clean && rm -rf node_modules",
118
107
  "check": "publint && attw --pack --ignore-rules internal-resolution-error",
119
- "test": "jest -i --config ./jest-config.json",
108
+ "test": "vitest run",
120
109
  "update-schemas": "npm run update-schema:alephium && npm run update-schema:explorer",
121
110
  "update-schema:alephium": "npx swagger-typescript-api --disable-throw-on-error -t ./configs -o ./src/api -n api-alephium.ts -p https://raw.githubusercontent.com/alephium/alephium/v${npm_package_config_alephium_version}/api/src/main/resources/openapi.json",
122
111
  "update-schema:explorer": "npx swagger-typescript-api --disable-throw-on-error -t ./configs -o ./src/api -n api-explorer.ts -p https://raw.githubusercontent.com/alephium/explorer-backend/v${npm_package_config_explorer_backend_version}/app/src/main/resources/explorer-backend-openapi.json",
@@ -723,6 +723,8 @@ export interface ContractEvent {
723
723
  blockHash: string
724
724
  /** @format 32-byte-hash */
725
725
  txId: string
726
+ /** @format int64 */
727
+ timestamp: number
726
728
  /** @format int32 */
727
729
  eventIndex: number
728
730
  fields: Val[]
@@ -732,6 +734,8 @@ export interface ContractEvent {
732
734
  export interface ContractEventByBlockHash {
733
735
  /** @format 32-byte-hash */
734
736
  txId: string
737
+ /** @format int64 */
738
+ timestamp: number
735
739
  /** @format address */
736
740
  contractAddress: string
737
741
  /** @format int32 */
@@ -743,6 +747,8 @@ export interface ContractEventByBlockHash {
743
747
  export interface ContractEventByTxId {
744
748
  /** @format block-hash */
745
749
  blockHash: string
750
+ /** @format int64 */
751
+ timestamp: number
746
752
  /** @format address */
747
753
  contractAddress: string
748
754
  /** @format int32 */
@@ -1503,7 +1509,7 @@ export interface ValByteVec {
1503
1509
 
1504
1510
  /** ValI256 */
1505
1511
  export interface ValI256 {
1506
- /** @format bigint */
1512
+ /** @format int256 */
1507
1513
  value: string
1508
1514
  type: string
1509
1515
  }
@@ -1779,7 +1785,7 @@ export class HttpClient<SecurityDataType = unknown> {
1779
1785
 
1780
1786
  /**
1781
1787
  * @title Alephium API
1782
- * @version 4.2.5
1788
+ * @version 4.4.1
1783
1789
  * @baseUrl ../
1784
1790
  */
1785
1791
  export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDataType> {
@@ -371,15 +371,14 @@ export class Contract extends Artifact {
371
371
  )
372
372
  }
373
373
 
374
- // support both 'code.ral' and 'code.ral.json'
375
374
  static async fromArtifactFile(
376
375
  path: string,
376
+ readFile: (path: string) => Promise<string | Uint8Array>,
377
377
  bytecodeDebugPatch: string,
378
378
  codeHashDebug: string,
379
379
  structs: Struct[] = []
380
380
  ): Promise<Contract> {
381
- const fs = await import('fs')
382
- const content = await fs.promises.readFile(path)
381
+ const content = await readFile(path)
383
382
  const artifact = JSON.parse(content.toString())
384
383
  return Contract.fromJson(artifact, bytecodeDebugPatch, codeHashDebug, structs)
385
384
  }
@@ -568,6 +567,7 @@ export class Contract extends Artifact {
568
567
  return {
569
568
  txId: txId,
570
569
  blockHash: event.blockHash,
570
+ timestamp: event.timestamp,
571
571
  contractAddress: event.contractAddress,
572
572
  name: name,
573
573
  eventIndex: event.eventIndex,
@@ -779,9 +779,13 @@ export class Script extends Artifact {
779
779
  )
780
780
  }
781
781
 
782
- static async fromArtifactFile(path: string, bytecodeDebugPatch: string, structs: Struct[] = []): Promise<Script> {
783
- const fs = await import('fs')
784
- const content = await fs.promises.readFile(path)
782
+ static async fromArtifactFile(
783
+ path: string,
784
+ readFile: (path: string) => Promise<string | Uint8Array>,
785
+ bytecodeDebugPatch: string,
786
+ structs: Struct[] = []
787
+ ): Promise<Script> {
788
+ const content = await readFile(path)
785
789
  const artifact = JSON.parse(content.toString())
786
790
  return this.fromJson(artifact, bytecodeDebugPatch, structs)
787
791
  }
@@ -1011,6 +1015,7 @@ export interface TestContractParams<
1011
1015
  export interface ContractEvent<T extends Fields = Fields> {
1012
1016
  txId: string
1013
1017
  blockHash: string
1018
+ timestamp: number
1014
1019
  contractAddress: string
1015
1020
  eventIndex: number
1016
1021
  name: string
@@ -1304,6 +1309,7 @@ export function decodeContractCreatedEvent(event: node.ContractEvent): Omit<Cont
1304
1309
  return {
1305
1310
  blockHash: event.blockHash,
1306
1311
  txId: event.txId,
1312
+ timestamp: event.timestamp,
1307
1313
  eventIndex: event.eventIndex,
1308
1314
  name: Contract.ContractCreatedEvent.name,
1309
1315
  fields: toContractCreatedEventFields(fields)
@@ -1317,6 +1323,7 @@ export function decodeContractDestroyedEvent(
1317
1323
  return {
1318
1324
  blockHash: event.blockHash,
1319
1325
  txId: event.txId,
1326
+ timestamp: event.timestamp,
1320
1327
  eventIndex: event.eventIndex,
1321
1328
  name: Contract.ContractDestroyedEvent.name,
1322
1329
  fields: { address: fields['address'] as Address }
package/src/index.ts CHANGED
@@ -16,19 +16,19 @@ You should have received a copy of the GNU Lesser General Public License
16
16
  along with the library. If not, see <http://www.gnu.org/licenses/>.
17
17
  */
18
18
 
19
- export * from './api/index'
20
- export * from './contract/index'
21
- export * from './signer/index'
22
- export * from './utils/index'
23
- export * from './transaction/index'
24
- export * from './token/index'
19
+ export * from './api'
20
+ export * from './contract'
21
+ export * from './signer'
22
+ export * from './utils'
23
+ export * from './transaction'
24
+ export * from './token'
25
25
 
26
26
  export * from './constants'
27
27
  export * as web3 from './global'
28
- export * as codec from './codec/index'
29
- export * as utils from './utils/index'
28
+ export * as codec from './codec'
29
+ export * as utils from './utils'
30
30
  export * from './debug'
31
- export * from './block/index'
32
- export * from './address/index'
33
- export * from './exchange/index'
31
+ export * from './block'
32
+ export * from './address'
33
+ export * from './exchange'
34
34
  export * from './error'
package/src/utils/sign.ts CHANGED
@@ -16,7 +16,7 @@ You should have received a copy of the GNU Lesser General Public License
16
16
  along with the library. If not, see <http://www.gnu.org/licenses/>.
17
17
  */
18
18
 
19
- import { binToHex, encodeSignature, hexToBinUnsafe, signatureDecode } from '../utils'
19
+ import { binToHex, encodeSignature, hexToBinUnsafe } from '../utils'
20
20
  import { KeyType } from '../signer'
21
21
  import * as secp from '@noble/secp256k1'
22
22
  import { sha256 } from '@noble/hashes/sha256'
@@ -61,8 +61,7 @@ export function verifySignature(hash: string, publicKey: string, signature: stri
61
61
 
62
62
  try {
63
63
  if (keyType === 'default' || keyType === 'gl-secp256k1') {
64
- const decoded = signatureDecode(signature)
65
- const sig = secp.Signature.fromCompact(decoded.r + decoded.s)
64
+ const sig = secp.Signature.fromCompact(signature)
66
65
  return secp.verify(sig, hexToBinUnsafe(hash), hexToBinUnsafe(publicKey))
67
66
  } else {
68
67
  return secp.schnorr.verifySync(hexToBinUnsafe(signature), hexToBinUnsafe(hash), hexToBinUnsafe(publicKey))