diff --git a/.changes/added/988.md b/.changes/added/988.md new file mode 100644 index 0000000000..fe9ea97210 --- /dev/null +++ b/.changes/added/988.md @@ -0,0 +1 @@ +New ID function exports to TypeScript WASM target. diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 639ed56038..8ea479f01d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -304,6 +304,9 @@ jobs: if: github.event_name == 'release' && github.event.action == 'published' runs-on: buildjet-4vcpu-ubuntu-2204 environment: npm-deploy + permissions: + id-token: write + contents: read steps: - uses: actions/checkout@v3 with: @@ -327,22 +330,21 @@ jobs: uses: actions/setup-node@v3 with: cache: "pnpm" - node-version: 18.14.1 + node-version: 22.22.0 node-version-file: ".npm/package.json" cache-dependency-path: ".npm/pnpm-lock.yaml" registry-url: 'https://registry.npmjs.org' + # Ensure latest NPM is installed to support OIDC publishing + - name: Update npm + run: npm install -g npm@11 + - name: Build and Test packages run: | pnpm -C .npm install pnpm -C .npm pack:all - - name: Ensure NPM access - run: npm whoami - env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN_VM }} - - name: Publish run: pnpm -C .npm publish -r --access public --no-git-checks env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN_VM }} + NPM_CONFIG_PROVENANCE: "true" diff --git a/.gitignore b/.gitignore index 7f3c53abac..24739b5116 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,5 @@ Cargo.lock .idea .history + +.pnpm-store diff --git a/.npm/.scripts/prepare-wasm-packages.sh b/.npm/.scripts/prepare-wasm-packages.sh index 810b0c4bf7..c013c034bc 100755 --- a/.npm/.scripts/prepare-wasm-packages.sh +++ b/.npm/.scripts/prepare-wasm-packages.sh @@ -48,6 +48,9 @@ build_wasm_npm_pkg_for () write_template ${NAME_DASHED} ${NAME_UNDERSCORED} package.json write_template ${NAME_DASHED} ${NAME_UNDERSCORED} rollup.config.mjs write_template ${NAME_DASHED} ${NAME_UNDERSCORED} src/index.js + write_template ${NAME_DASHED} ${NAME_UNDERSCORED} src/index_slim.js + write_template ${NAME_DASHED} ${NAME_UNDERSCORED} src/index.d.ts + write_template ${NAME_DASHED} ${NAME_UNDERSCORED} src/index_slim.d.ts # commenting out all `new URL()` and `fetch()` calls for great compatibility with JS bundlers sed -i.bkp -r 's;(.+= new URL.+);//\1;g' ${PKG_DIR}/src/${NAME_UNDERSCORED}.js diff --git a/.npm/.scripts/template/README.md b/.npm/.scripts/template/README.md index bbbe7cb404..5ef5c26263 100644 --- a/.npm/.scripts/template/README.md +++ b/.npm/.scripts/template/README.md @@ -6,18 +6,35 @@ WASM version of `{{NAME_DASHED}}` Rust crate: - https://github.com/FuelLabs/fuel-vm/tree/master/{{NAME_DASHED}} -# Getting Started +## Getting Started -Be sure to `await` the WASM async initialization: +### Standard Usage (Browser / Node.js) + +The default entrypoint includes WASM inlined as base64: ```ts import * as {{NAME_UNDERSCORED}} from '@fuels/vm-{{PKG_NAME}}' -(async function() { - await {{NAME_UNDERSCORED}}.initWasm(); +await {{NAME_UNDERSCORED}}.initWasm(); + +// {{NAME_UNDERSCORED}}.(); +// ... +``` + +### Slim Usage (Cloudflare Workers / Custom WASM Loading) + +The `/slim` entrypoint omits the inlined WASM, requiring you to supply it. +This is necessary for environments like Cloudflare Workers where runtime WASM +compilation is disallowed. + +#### Cloudflare Workers + +```ts +import * as {{NAME_UNDERSCORED}} from '@fuels/vm-{{PKG_NAME}}/slim' +import wasm from '@fuels/vm-{{PKG_NAME}}/wasm' - // {{NAME_UNDERSCORED}}.(); - // ... -})(); +await {{NAME_UNDERSCORED}}.initWasm(wasm); +// {{NAME_UNDERSCORED}}.(); +// ... ``` diff --git a/.npm/.scripts/template/package.json b/.npm/.scripts/template/package.json index c1a81c2314..b5827a8ea7 100644 --- a/.npm/.scripts/template/package.json +++ b/.npm/.scripts/template/package.json @@ -6,6 +6,28 @@ "main": "dist/node/index.cjs", "types": "dist/node/index.d.ts", "browser": "dist/web/index.mjs", + "exports": { + ".": { + "node": { + "types": "./dist/node/index.d.ts", + "default": "./dist/node/index.cjs" + }, + "types": "./dist/web/index.d.ts", + "import": "./dist/web/index.mjs", + "default": "./dist/node/index.cjs" + }, + "./slim": { + "types": "./dist/slim/index.d.ts", + "import": "./dist/slim/index.mjs", + "require": "./dist/slim/index.cjs" + }, + "./wasm": "./dist/{{NAME_UNDERSCORED}}_bg.wasm", + "./package.json": "./package.json" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/FuelLabs/fuel-vm.git" + }, "files": [ "dist" ], diff --git a/.npm/.scripts/template/rollup.config.mjs b/.npm/.scripts/template/rollup.config.mjs index abf9e8091f..4362e62219 100644 --- a/.npm/.scripts/template/rollup.config.mjs +++ b/.npm/.scripts/template/rollup.config.mjs @@ -1,27 +1,52 @@ import { wasm } from '@rollup/plugin-wasm' import dts from 'rollup-plugin-dts' +import { copyFileSync } from 'node:fs' const sync = ['src/{{NAME_UNDERSCORED}}_bg.wasm']; +const copyWasm = { + name: 'copy-wasm', + writeBundle() { + copyFileSync('src/{{NAME_UNDERSCORED}}_bg.wasm', 'dist/{{NAME_UNDERSCORED}}_bg.wasm'); + } +}; + export default [ { - plugins: [wasm({ sync, targetEnv: 'auto-inline' })], + plugins: [wasm({ sync, targetEnv: 'auto' })], input: 'src/index.js', output: [ { file: 'dist/node/index.cjs', format: 'cjs' }, ] }, { - plugins: [wasm({ sync, targetEnv: 'auto-inline' })], + plugins: [wasm({ sync, targetEnv: 'auto' })], input: 'src/index.js', output: [ { file: 'dist/web/index.mjs', format: 'es' }, ] + }, { + input: 'src/index_slim.js', + output: [ + { file: 'dist/slim/index.cjs', format: 'cjs' }, + ] + }, { + plugins: [copyWasm], + input: 'src/index_slim.js', + output: [ + { file: 'dist/slim/index.mjs', format: 'es' }, + ] }, { plugins: [dts()], - input: 'src/{{NAME_UNDERSCORED}}.d.ts', + input: 'src/index.d.ts', output: [ { file: 'dist/web/index.d.ts', format: 'es' }, - { file: 'dist/node/index.d.ts', format: 'es' } + { file: 'dist/node/index.d.ts', format: 'es' }, + ], + }, { + plugins: [dts()], + input: 'src/index_slim.d.ts', + output: [ + { file: 'dist/slim/index.d.ts', format: 'es' }, ], } ] diff --git a/.npm/.scripts/template/src/index.d.ts b/.npm/.scripts/template/src/index.d.ts new file mode 100644 index 0000000000..2e6f26c044 --- /dev/null +++ b/.npm/.scripts/template/src/index.d.ts @@ -0,0 +1,9 @@ +export * from './{{NAME_UNDERSCORED}}.js'; + +export type InitInput = + | WebAssembly.Module + | BufferSource + | Response + | Promise; + +export function initWasm(module_or_path?: InitInput): Promise; diff --git a/.npm/.scripts/template/src/index.js b/.npm/.scripts/template/src/index.js index a1c711433e..8117139ce3 100644 --- a/.npm/.scripts/template/src/index.js +++ b/.npm/.scripts/template/src/index.js @@ -1,14 +1,15 @@ import init from './{{NAME_UNDERSCORED}}.js' -import wasm from './{{NAME_UNDERSCORED}}_bg.wasm' +import wasmModule from './{{NAME_UNDERSCORED}}_bg.wasm' -export async function initWasm () { - return await init({ module_or_path: wasm() }); +let _initPromise; + +export async function initWasm (module_or_path) { + if (!_initPromise) { + _initPromise = init({ module_or_path: module_or_path ?? wasmModule() }); + } + return _initPromise; } -/** - * calling it right away for pre-caching - * the wasm async initialization at startup - */ initWasm(); export * from './{{NAME_UNDERSCORED}}.js' diff --git a/.npm/.scripts/template/src/index_slim.d.ts b/.npm/.scripts/template/src/index_slim.d.ts new file mode 100644 index 0000000000..0bf56e61f3 --- /dev/null +++ b/.npm/.scripts/template/src/index_slim.d.ts @@ -0,0 +1,9 @@ +export * from './{{NAME_UNDERSCORED}}.js'; + +export type InitInput = + | WebAssembly.Module + | BufferSource + | Response + | Promise; + +export function initWasm(module_or_path: InitInput): Promise; diff --git a/.npm/.scripts/template/src/index_slim.js b/.npm/.scripts/template/src/index_slim.js new file mode 100644 index 0000000000..fd6cdefbda --- /dev/null +++ b/.npm/.scripts/template/src/index_slim.js @@ -0,0 +1,18 @@ +import init from './{{NAME_UNDERSCORED}}.js' + +let _initPromise; + +export async function initWasm (module_or_path) { + if (!_initPromise) { + if (module_or_path == null) { + throw new Error( + '@fuels/vm-{{PKG_NAME}}/slim: initWasm() requires a WebAssembly.Module or BufferSource. ' + + 'Use "@fuels/vm-{{PKG_NAME}}" for automatic WASM loading.' + ); + } + _initPromise = init({ module_or_path }); + } + return _initPromise; +} + +export * from './{{NAME_UNDERSCORED}}.js' diff --git a/.npm/package.json b/.npm/package.json index d9c88ac67e..7932dbff36 100644 --- a/.npm/package.json +++ b/.npm/package.json @@ -21,8 +21,8 @@ "chai": "^4.3.10", "mocha": "^10.2.0", "npm-run-all": "^4.1.5", - "rollup": "^3.29.4", - "rollup-plugin-dts": "^5.3.1", + "rollup": "^4.57.1", + "rollup-plugin-dts": "^6.3.0", "turbo": "^2.1.2" } diff --git a/.npm/pnpm-lock.yaml b/.npm/pnpm-lock.yaml index ccbf64ea7b..3db765eb60 100644 --- a/.npm/pnpm-lock.yaml +++ b/.npm/pnpm-lock.yaml @@ -10,7 +10,7 @@ importers: devDependencies: '@rollup/plugin-wasm': specifier: ^6.2.2 - version: 6.2.2(rollup@3.29.4) + version: 6.2.2(rollup@4.57.1) chai: specifier: ^4.3.10 version: 4.3.10 @@ -21,11 +21,11 @@ importers: specifier: ^4.1.5 version: 4.1.5 rollup: - specifier: ^3.29.4 - version: 3.29.4 + specifier: ^4.57.1 + version: 4.57.1 rollup-plugin-dts: - specifier: ^5.3.1 - version: 5.3.1(rollup@3.29.4)(typescript@5.3.2) + specifier: ^6.3.0 + version: 6.3.0(rollup@4.57.1)(typescript@5.3.2) turbo: specifier: ^2.1.2 version: 2.1.2 @@ -38,20 +38,16 @@ importers: packages: - '@babel/code-frame@7.23.5': - resolution: {integrity: sha512-CgH3s1a96LipHCmSUmYFPwY7MNx8C3avkq7i4Wl3cfa662ldtUe4VM1TPXX70pfmrlWTb6jLqTYrZyT2ZTJBgA==} + '@babel/code-frame@7.29.0': + resolution: {integrity: sha512-9NhCeYjq9+3uxgdtp20LSiJXJvN0FeCtNGpJxuMFZ1Kv3cWUNb6DOhJwUvcVCzKGR66cw4njwM6hrJLqgOwbcw==} engines: {node: '>=6.9.0'} - '@babel/helper-validator-identifier@7.22.20': - resolution: {integrity: sha512-Y4OZ+ytlatR8AI+8KZfKuL5urKp7qey08ha31L8b3BwewJAoJamTzyvxPR/5D+KkdJCGPq/+8TukHBlY10FX9A==} + '@babel/helper-validator-identifier@7.28.5': + resolution: {integrity: sha512-qSs4ifwzKJSV39ucNjsvc6WVHs6b7S03sOh2OcHF9UHfVPqWWALUsNUVzhSBiItjRZoLHx7nIarVjqKVusUZ1Q==} engines: {node: '>=6.9.0'} - '@babel/highlight@7.23.4': - resolution: {integrity: sha512-acGdbYSfp2WheJoJm/EBBBLh/ID8KDc64ISZ9DYtBmC8/Q204PZJLHyzeB5qMzJ5trcOkybd78M4x2KWsUq++A==} - engines: {node: '>=6.9.0'} - - '@jridgewell/sourcemap-codec@1.4.15': - resolution: {integrity: sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==} + '@jridgewell/sourcemap-codec@1.5.5': + resolution: {integrity: sha512-cYQ9310grqxueWbl+WuIUIaiUaDcj7WOq5fVhEljNVgRfOUhY9fy2zTvfoqWsnebh8Sl70VScFbICvJnLKB0Og==} '@rollup/plugin-wasm@6.2.2': resolution: {integrity: sha512-gpC4R1G9Ni92ZIRTexqbhX7U+9estZrbhP+9SRb0DW9xpB9g7j34r+J2hqrcW/lRI7dJaU84MxZM0Rt82tqYPQ==} @@ -71,9 +67,137 @@ packages: rollup: optional: true + '@rollup/rollup-android-arm-eabi@4.57.1': + resolution: {integrity: sha512-A6ehUVSiSaaliTxai040ZpZ2zTevHYbvu/lDoeAteHI8QnaosIzm4qwtezfRg1jOYaUmnzLX1AOD6Z+UJjtifg==} + cpu: [arm] + os: [android] + + '@rollup/rollup-android-arm64@4.57.1': + resolution: {integrity: sha512-dQaAddCY9YgkFHZcFNS/606Exo8vcLHwArFZ7vxXq4rigo2bb494/xKMMwRRQW6ug7Js6yXmBZhSBRuBvCCQ3w==} + cpu: [arm64] + os: [android] + + '@rollup/rollup-darwin-arm64@4.57.1': + resolution: {integrity: sha512-crNPrwJOrRxagUYeMn/DZwqN88SDmwaJ8Cvi/TN1HnWBU7GwknckyosC2gd0IqYRsHDEnXf328o9/HC6OkPgOg==} + cpu: [arm64] + os: [darwin] + + '@rollup/rollup-darwin-x64@4.57.1': + resolution: {integrity: sha512-Ji8g8ChVbKrhFtig5QBV7iMaJrGtpHelkB3lsaKzadFBe58gmjfGXAOfI5FV0lYMH8wiqsxKQ1C9B0YTRXVy4w==} + cpu: [x64] + os: [darwin] + + '@rollup/rollup-freebsd-arm64@4.57.1': + resolution: {integrity: sha512-R+/WwhsjmwodAcz65guCGFRkMb4gKWTcIeLy60JJQbXrJ97BOXHxnkPFrP+YwFlaS0m+uWJTstrUA9o+UchFug==} + cpu: [arm64] + os: [freebsd] + + '@rollup/rollup-freebsd-x64@4.57.1': + resolution: {integrity: sha512-IEQTCHeiTOnAUC3IDQdzRAGj3jOAYNr9kBguI7MQAAZK3caezRrg0GxAb6Hchg4lxdZEI5Oq3iov/w/hnFWY9Q==} + cpu: [x64] + os: [freebsd] + + '@rollup/rollup-linux-arm-gnueabihf@4.57.1': + resolution: {integrity: sha512-F8sWbhZ7tyuEfsmOxwc2giKDQzN3+kuBLPwwZGyVkLlKGdV1nvnNwYD0fKQ8+XS6hp9nY7B+ZeK01EBUE7aHaw==} + cpu: [arm] + os: [linux] + + '@rollup/rollup-linux-arm-musleabihf@4.57.1': + resolution: {integrity: sha512-rGfNUfn0GIeXtBP1wL5MnzSj98+PZe/AXaGBCRmT0ts80lU5CATYGxXukeTX39XBKsxzFpEeK+Mrp9faXOlmrw==} + cpu: [arm] + os: [linux] + + '@rollup/rollup-linux-arm64-gnu@4.57.1': + resolution: {integrity: sha512-MMtej3YHWeg/0klK2Qodf3yrNzz6CGjo2UntLvk2RSPlhzgLvYEB3frRvbEF2wRKh1Z2fDIg9KRPe1fawv7C+g==} + cpu: [arm64] + os: [linux] + + '@rollup/rollup-linux-arm64-musl@4.57.1': + resolution: {integrity: sha512-1a/qhaaOXhqXGpMFMET9VqwZakkljWHLmZOX48R0I/YLbhdxr1m4gtG1Hq7++VhVUmf+L3sTAf9op4JlhQ5u1Q==} + cpu: [arm64] + os: [linux] + + '@rollup/rollup-linux-loong64-gnu@4.57.1': + resolution: {integrity: sha512-QWO6RQTZ/cqYtJMtxhkRkidoNGXc7ERPbZN7dVW5SdURuLeVU7lwKMpo18XdcmpWYd0qsP1bwKPf7DNSUinhvA==} + cpu: [loong64] + os: [linux] + + '@rollup/rollup-linux-loong64-musl@4.57.1': + resolution: {integrity: sha512-xpObYIf+8gprgWaPP32xiN5RVTi/s5FCR+XMXSKmhfoJjrpRAjCuuqQXyxUa/eJTdAE6eJ+KDKaoEqjZQxh3Gw==} + cpu: [loong64] + os: [linux] + + '@rollup/rollup-linux-ppc64-gnu@4.57.1': + resolution: {integrity: sha512-4BrCgrpZo4hvzMDKRqEaW1zeecScDCR+2nZ86ATLhAoJ5FQ+lbHVD3ttKe74/c7tNT9c6F2viwB3ufwp01Oh2w==} + cpu: [ppc64] + os: [linux] + + '@rollup/rollup-linux-ppc64-musl@4.57.1': + resolution: {integrity: sha512-NOlUuzesGauESAyEYFSe3QTUguL+lvrN1HtwEEsU2rOwdUDeTMJdO5dUYl/2hKf9jWydJrO9OL/XSSf65R5+Xw==} + cpu: [ppc64] + os: [linux] + + '@rollup/rollup-linux-riscv64-gnu@4.57.1': + resolution: {integrity: sha512-ptA88htVp0AwUUqhVghwDIKlvJMD/fmL/wrQj99PRHFRAG6Z5nbWoWG4o81Nt9FT+IuqUQi+L31ZKAFeJ5Is+A==} + cpu: [riscv64] + os: [linux] + + '@rollup/rollup-linux-riscv64-musl@4.57.1': + resolution: {integrity: sha512-S51t7aMMTNdmAMPpBg7OOsTdn4tySRQvklmL3RpDRyknk87+Sp3xaumlatU+ppQ+5raY7sSTcC2beGgvhENfuw==} + cpu: [riscv64] + os: [linux] + + '@rollup/rollup-linux-s390x-gnu@4.57.1': + resolution: {integrity: sha512-Bl00OFnVFkL82FHbEqy3k5CUCKH6OEJL54KCyx2oqsmZnFTR8IoNqBF+mjQVcRCT5sB6yOvK8A37LNm/kPJiZg==} + cpu: [s390x] + os: [linux] + + '@rollup/rollup-linux-x64-gnu@4.57.1': + resolution: {integrity: sha512-ABca4ceT4N+Tv/GtotnWAeXZUZuM/9AQyCyKYyKnpk4yoA7QIAuBt6Hkgpw8kActYlew2mvckXkvx0FfoInnLg==} + cpu: [x64] + os: [linux] + + '@rollup/rollup-linux-x64-musl@4.57.1': + resolution: {integrity: sha512-HFps0JeGtuOR2convgRRkHCekD7j+gdAuXM+/i6kGzQtFhlCtQkpwtNzkNj6QhCDp7DRJ7+qC/1Vg2jt5iSOFw==} + cpu: [x64] + os: [linux] + + '@rollup/rollup-openbsd-x64@4.57.1': + resolution: {integrity: sha512-H+hXEv9gdVQuDTgnqD+SQffoWoc0Of59AStSzTEj/feWTBAnSfSD3+Dql1ZruJQxmykT/JVY0dE8Ka7z0DH1hw==} + cpu: [x64] + os: [openbsd] + + '@rollup/rollup-openharmony-arm64@4.57.1': + resolution: {integrity: sha512-4wYoDpNg6o/oPximyc/NG+mYUejZrCU2q+2w6YZqrAs2UcNUChIZXjtafAiiZSUc7On8v5NyNj34Kzj/Ltk6dQ==} + cpu: [arm64] + os: [openharmony] + + '@rollup/rollup-win32-arm64-msvc@4.57.1': + resolution: {integrity: sha512-O54mtsV/6LW3P8qdTcamQmuC990HDfR71lo44oZMZlXU4tzLrbvTii87Ni9opq60ds0YzuAlEr/GNwuNluZyMQ==} + cpu: [arm64] + os: [win32] + + '@rollup/rollup-win32-ia32-msvc@4.57.1': + resolution: {integrity: sha512-P3dLS+IerxCT/7D2q2FYcRdWRl22dNbrbBEtxdWhXrfIMPP9lQhb5h4Du04mdl5Woq05jVCDPCMF7Ub0NAjIew==} + cpu: [ia32] + os: [win32] + + '@rollup/rollup-win32-x64-gnu@4.57.1': + resolution: {integrity: sha512-VMBH2eOOaKGtIJYleXsi2B8CPVADrh+TyNxJ4mWPnKfLB/DBUmzW+5m1xUrcwWoMfSLagIRpjUFeW5CO5hyciQ==} + cpu: [x64] + os: [win32] + + '@rollup/rollup-win32-x64-msvc@4.57.1': + resolution: {integrity: sha512-mxRFDdHIWRxg3UfIIAwCm6NzvxG0jDX/wBN6KsQFTvKFqqg9vTrWUE68qEjHt19A5wwx5X5aUi2zuZT7YR0jrA==} + cpu: [x64] + os: [win32] + '@types/estree@1.0.5': resolution: {integrity: sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw==} + '@types/estree@1.0.8': + resolution: {integrity: sha512-dWHzHa2WqEXI/O1E9OjrocMTKJl2mSrEolh1Iomrv6U+JuNwaHXsXx9bLu5gG7BUWFIN0skIQJQ/L1rIex4X6w==} + ansi-colors@4.1.1: resolution: {integrity: sha512-JoX0apGbHaUJBNl6yF+p6JAFYZ666/hhCGKN5t9QFjbJQKUU/g8MNbFDbvfrgKXvI1QpZplPOnwIo99lX/AAmA==} engines: {node: '>=6'} @@ -466,9 +590,8 @@ packages: loupe@2.3.7: resolution: {integrity: sha512-zSMINGVYkdpYSOBmLi0D1Uo7JU9nVdQKrHxC8eYlV+9YKK9WePqAlL7lSlorG/U2Fw1w0hTBmaa/jrQ3UbPHtA==} - magic-string@0.30.5: - resolution: {integrity: sha512-7xlpfBaQaP/T6Vh8MO/EqXSW5En6INHEvEXQiuff7Gku0PWjU3uf6w/j9o7O+SpB5fOAkrI5HeoNgwjEO0pFsA==} - engines: {node: '>=12'} + magic-string@0.30.21: + resolution: {integrity: sha512-vd2F4YUyEXKGcLHoq+TEyCjxueSeHnFxyyjNp80yg0XV4vUhnDer/lvvlqM/arB5bXQN5K2/3oinyCRyx8T2CQ==} memorystream@0.3.1: resolution: {integrity: sha512-S3UwM3yj5mtUSEfP41UZmt/0SCoVYUcU1rkXv+BQ5Ig8ndL4sPoJNBUJERafdPb5jjHJGuMgytgKvKIf58XNBw==} @@ -560,6 +683,9 @@ packages: pathval@1.1.1: resolution: {integrity: sha512-Dp6zGqpTdETdR63lehJYPeIOqpiNBNtc7BpWSLrOje7UaIsE5aY92r/AunQA7rsXvet3lrJ3JnZX29UPTKXyKQ==} + picocolors@1.1.1: + resolution: {integrity: sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==} + picomatch@2.3.1: resolution: {integrity: sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==} engines: {node: '>=8.6'} @@ -596,16 +722,16 @@ packages: resolution: {integrity: sha512-oKWePCxqpd6FlLvGV1VU0x7bkPmmCNolxzjMf4NczoDnQcIWrAF+cPtZn5i6n+RfD2d9i0tzpKnG6Yk168yIyw==} hasBin: true - rollup-plugin-dts@5.3.1: - resolution: {integrity: sha512-gusMi+Z4gY/JaEQeXnB0RUdU82h1kF0WYzCWgVmV4p3hWXqelaKuCvcJawfeg+EKn2T1Ie+YWF2OiN1/L8bTVg==} - engines: {node: '>=v14.21.3'} + rollup-plugin-dts@6.3.0: + resolution: {integrity: sha512-d0UrqxYd8KyZ6i3M2Nx7WOMy708qsV/7fTHMHxCMCBOAe3V/U7OMPu5GkX8hC+cmkHhzGnfeYongl1IgiooddA==} + engines: {node: '>=16'} peerDependencies: - rollup: ^3.0 - typescript: ^4.1 || ^5.0 + rollup: ^3.29.4 || ^4 + typescript: ^4.5 || ^5.0 - rollup@3.29.4: - resolution: {integrity: sha512-oWzmBZwvYrU0iJHtDmhsm662rC15FRXmcjCk1xD771dFDx5jJ02ufAQQTn0etB2emNk4J9EZg/yWKpsn9BWGRw==} - engines: {node: '>=14.18.0', npm: '>=8.0.0'} + rollup@4.57.1: + resolution: {integrity: sha512-oQL6lgK3e2QZeQ7gcgIkS2YZPg5slw37hYufJ3edKlfQSGGm8ICoxswK15ntSzF/a8+h7ekRy7k7oWc3BQ7y8A==} + engines: {node: '>=18.0.0', npm: '>=8.0.0'} hasBin: true safe-array-concat@1.0.1: @@ -816,40 +942,111 @@ packages: snapshots: - '@babel/code-frame@7.23.5': + '@babel/code-frame@7.29.0': dependencies: - '@babel/highlight': 7.23.4 - chalk: 2.4.2 - optional: true - - '@babel/helper-validator-identifier@7.22.20': + '@babel/helper-validator-identifier': 7.28.5 + js-tokens: 4.0.0 + picocolors: 1.1.1 optional: true - '@babel/highlight@7.23.4': - dependencies: - '@babel/helper-validator-identifier': 7.22.20 - chalk: 2.4.2 - js-tokens: 4.0.0 + '@babel/helper-validator-identifier@7.28.5': optional: true - '@jridgewell/sourcemap-codec@1.4.15': {} + '@jridgewell/sourcemap-codec@1.5.5': {} - '@rollup/plugin-wasm@6.2.2(rollup@3.29.4)': + '@rollup/plugin-wasm@6.2.2(rollup@4.57.1)': dependencies: - '@rollup/pluginutils': 5.1.0(rollup@3.29.4) + '@rollup/pluginutils': 5.1.0(rollup@4.57.1) optionalDependencies: - rollup: 3.29.4 + rollup: 4.57.1 - '@rollup/pluginutils@5.1.0(rollup@3.29.4)': + '@rollup/pluginutils@5.1.0(rollup@4.57.1)': dependencies: '@types/estree': 1.0.5 estree-walker: 2.0.2 picomatch: 2.3.1 optionalDependencies: - rollup: 3.29.4 + rollup: 4.57.1 + + '@rollup/rollup-android-arm-eabi@4.57.1': + optional: true + + '@rollup/rollup-android-arm64@4.57.1': + optional: true + + '@rollup/rollup-darwin-arm64@4.57.1': + optional: true + + '@rollup/rollup-darwin-x64@4.57.1': + optional: true + + '@rollup/rollup-freebsd-arm64@4.57.1': + optional: true + + '@rollup/rollup-freebsd-x64@4.57.1': + optional: true + + '@rollup/rollup-linux-arm-gnueabihf@4.57.1': + optional: true + + '@rollup/rollup-linux-arm-musleabihf@4.57.1': + optional: true + + '@rollup/rollup-linux-arm64-gnu@4.57.1': + optional: true + + '@rollup/rollup-linux-arm64-musl@4.57.1': + optional: true + + '@rollup/rollup-linux-loong64-gnu@4.57.1': + optional: true + + '@rollup/rollup-linux-loong64-musl@4.57.1': + optional: true + + '@rollup/rollup-linux-ppc64-gnu@4.57.1': + optional: true + + '@rollup/rollup-linux-ppc64-musl@4.57.1': + optional: true + + '@rollup/rollup-linux-riscv64-gnu@4.57.1': + optional: true + + '@rollup/rollup-linux-riscv64-musl@4.57.1': + optional: true + + '@rollup/rollup-linux-s390x-gnu@4.57.1': + optional: true + + '@rollup/rollup-linux-x64-gnu@4.57.1': + optional: true + + '@rollup/rollup-linux-x64-musl@4.57.1': + optional: true + + '@rollup/rollup-openbsd-x64@4.57.1': + optional: true + + '@rollup/rollup-openharmony-arm64@4.57.1': + optional: true + + '@rollup/rollup-win32-arm64-msvc@4.57.1': + optional: true + + '@rollup/rollup-win32-ia32-msvc@4.57.1': + optional: true + + '@rollup/rollup-win32-x64-gnu@4.57.1': + optional: true + + '@rollup/rollup-win32-x64-msvc@4.57.1': + optional: true '@types/estree@1.0.5': {} + '@types/estree@1.0.8': {} + ansi-colors@4.1.1: {} ansi-regex@5.0.1: {} @@ -1292,9 +1489,9 @@ snapshots: dependencies: get-func-name: 2.0.2 - magic-string@0.30.5: + magic-string@0.30.21: dependencies: - '@jridgewell/sourcemap-codec': 1.4.15 + '@jridgewell/sourcemap-codec': 1.5.5 memorystream@0.3.1: {} @@ -1401,6 +1598,9 @@ snapshots: pathval@1.1.1: {} + picocolors@1.1.1: + optional: true + picomatch@2.3.1: {} pidtree@0.3.1: {} @@ -1435,16 +1635,43 @@ snapshots: path-parse: 1.0.7 supports-preserve-symlinks-flag: 1.0.0 - rollup-plugin-dts@5.3.1(rollup@3.29.4)(typescript@5.3.2): + rollup-plugin-dts@6.3.0(rollup@4.57.1)(typescript@5.3.2): dependencies: - magic-string: 0.30.5 - rollup: 3.29.4 + magic-string: 0.30.21 + rollup: 4.57.1 typescript: 5.3.2 optionalDependencies: - '@babel/code-frame': 7.23.5 + '@babel/code-frame': 7.29.0 - rollup@3.29.4: + rollup@4.57.1: + dependencies: + '@types/estree': 1.0.8 optionalDependencies: + '@rollup/rollup-android-arm-eabi': 4.57.1 + '@rollup/rollup-android-arm64': 4.57.1 + '@rollup/rollup-darwin-arm64': 4.57.1 + '@rollup/rollup-darwin-x64': 4.57.1 + '@rollup/rollup-freebsd-arm64': 4.57.1 + '@rollup/rollup-freebsd-x64': 4.57.1 + '@rollup/rollup-linux-arm-gnueabihf': 4.57.1 + '@rollup/rollup-linux-arm-musleabihf': 4.57.1 + '@rollup/rollup-linux-arm64-gnu': 4.57.1 + '@rollup/rollup-linux-arm64-musl': 4.57.1 + '@rollup/rollup-linux-loong64-gnu': 4.57.1 + '@rollup/rollup-linux-loong64-musl': 4.57.1 + '@rollup/rollup-linux-ppc64-gnu': 4.57.1 + '@rollup/rollup-linux-ppc64-musl': 4.57.1 + '@rollup/rollup-linux-riscv64-gnu': 4.57.1 + '@rollup/rollup-linux-riscv64-musl': 4.57.1 + '@rollup/rollup-linux-s390x-gnu': 4.57.1 + '@rollup/rollup-linux-x64-gnu': 4.57.1 + '@rollup/rollup-linux-x64-musl': 4.57.1 + '@rollup/rollup-openbsd-x64': 4.57.1 + '@rollup/rollup-openharmony-arm64': 4.57.1 + '@rollup/rollup-win32-arm64-msvc': 4.57.1 + '@rollup/rollup-win32-ia32-msvc': 4.57.1 + '@rollup/rollup-win32-x64-gnu': 4.57.1 + '@rollup/rollup-win32-x64-msvc': 4.57.1 fsevents: 2.3.3 safe-array-concat@1.0.1: diff --git a/fuel-tx/src/transaction.rs b/fuel-tx/src/transaction.rs index 86cefd72b4..4596bc666e 100644 --- a/fuel-tx/src/transaction.rs +++ b/fuel-tx/src/transaction.rs @@ -1143,7 +1143,10 @@ pub mod typescript { string::String, vec::Vec, }; - use fuel_types::Bytes32; + use fuel_types::{ + Bytes32, + ChainId, + }; #[derive(Debug, Clone, Eq, Hash, PartialEq, serde::Serialize, serde::Deserialize)] #[wasm_bindgen] @@ -1209,6 +1212,18 @@ pub mod typescript { .map_err(|e| js_sys::Error::new(&format!("{:?}", e))) } + #[wasm_bindgen(js_name = id)] + pub fn typescript_id(&self, chain_id: &ChainId) -> Bytes32 { + use crate::UniqueIdentifier; + self.0.id(chain_id) + } + + #[wasm_bindgen(js_name = cachedId)] + pub fn typescript_cached_id(&self) -> Option { + use crate::UniqueIdentifier; + self.0.cached_id() + } + #[wasm_bindgen] pub fn script( gas_limit: Word, @@ -1368,6 +1383,18 @@ pub mod typescript { .map_err(|e| js_sys::Error::new(&format!("{:?}", e)))?; Ok(Self(Box::new(res))) } + + #[wasm_bindgen(js_name = id)] + pub fn typescript_id(&self, chain_id: &ChainId) -> Bytes32 { + use crate::UniqueIdentifier; + self.0.id(chain_id) + } + + #[wasm_bindgen(js_name = cachedId)] + pub fn typescript_cached_id(&self) -> Option { + use crate::UniqueIdentifier; + self.0.cached_id() + } } }; }