File tree Expand file tree Collapse file tree 2 files changed +39
-0
lines changed Expand file tree Collapse file tree 2 files changed +39
-0
lines changed Original file line number Diff line number Diff line change @@ -201,6 +201,16 @@ jobs:
201201 run : |
202202 cp result/cardano_node_grpc_web_pb.js cardano-wasm/lib-wrapper/
203203
204+ - name : Test NPM package with node.js
205+ run : |
206+ export TMPDIR=$(mktemp -d)
207+ cp cardano-wasm/node.test.js $TMPDIR/
208+ cp cardano-wasm/npm-wrapper/*.tgz $TMPDIR/
209+ cd $TMPDIR
210+ npm install ./*.tgz
211+ node node.test.js
212+ cd -
213+
204214 - name : Upload built wasm library
205215 uses : actions/upload-artifact@v4
206216 with :
Original file line number Diff line number Diff line change 1+ // Test snippet from NPM's package README.md
2+
3+ ( async ( ) => {
4+ try {
5+ // 1. Dynamically import the package.
6+ const cardanoModule = await import ( 'cardano-wasm' ) ;
7+
8+ // 2. The module's default export is an async function that initializes the WASM instance.
9+ // Await this to get the usable API object.
10+ const api = await cardanoModule . default ( ) ;
11+ console . log ( "Cardano API loaded successfully!" ) ;
12+
13+ // 3. Now you can use the API to perform Cardano operations.
14+ // For example, let's create a new transaction body.
15+ const tx = await api . tx . newTx ( ) ;
16+ console . log ( "New Transaction Body Created:" , tx ) ;
17+
18+ // You can now build upon the 'tx' object to add inputs, outputs, etc.
19+
20+ console . log ( "Test Passed." ) ;
21+ process . exit ( 0 ) ;
22+
23+ } catch ( error ) {
24+ console . error ( "Failed to load or use the Cardano API:" , error ) ;
25+
26+ console . log ( "Test Failed." ) ;
27+ process . exit ( 1 ) ;
28+ }
29+ } ) ( ) ;
You can’t perform that action at this time.
0 commit comments