(libraryPath, chainId, privateKey, apiKeyIndex, accountIndex, createClient = false)
| 1578 | return undefined; // c# stub |
| 1579 | } |
| 1580 | async loadLighterLibrary(libraryPath, chainId, privateKey, apiKeyIndex, accountIndex, createClient = false) { |
| 1581 | // wasmExecPathExample: '/opt/homebrew/opt/go/libexec/lib/wasm/wasm_exec.js'; |
| 1582 | // libraryPath eg: '/Users/cjg/Git/lighter-go/lighter.wasm'; |
| 1583 | if (libraryPath === undefined || libraryPath === '') { |
| 1584 | throw new Error('loadLighterLibrary() requires "libraryPath" that should point to "lighter.wasm".\nYou can build it from source using the official Ligher SDK or download it here https://github.com/ccxt/lighter-wasm.\nExample: exchanges.options["libraryPath"] = "/user/cjg/Git/lighter-wasm/lighter.wasm"'); |
| 1585 | } |
| 1586 | if (!isNode) { |
| 1587 | throw new NotSupported(this.id + ' loadLighterLibrary() is only supported in node environment.'); |
| 1588 | } |
| 1589 | await functions.initFileSystem(); |
| 1590 | const wasmExecPath = this.safeString(this.options, 'wasmExecPath'); |
| 1591 | if (wasmExecPath === undefined || wasmExecPath === '') { |
| 1592 | throw new Error('loadLighterLibrary() requires "wasmExecPath" that should point to `wasm_exec.js`. You can check the location of the file locally if you have GO installed or download it here https://github.com/ccxt/lighter-wasm.\nExample: exchanges.options["wasmExecPath"] = "/opt/homebrew/opt/go/libexec/lib/wasm/wasm_exec.js"'); |
| 1593 | } |
| 1594 | await import(filePathToFileUrlForWindows(wasmExecPath)); |
| 1595 | const go = new globalThis.Go(); |
| 1596 | // read wasm from disks |
| 1597 | const bytes = new Uint8Array(readFile(libraryPath, null)); // it should point to lighter.wasm |
| 1598 | const { instance } = await WebAssembly.instantiate(bytes, go.importObject); |
| 1599 | go.run(instance); |
| 1600 | if (createClient) { |
| 1601 | this.lighterCreateClient(undefined, chainId, privateKey, apiKeyIndex, accountIndex); |
| 1602 | } |
| 1603 | return {}; // empty object we will read it from globalThis |
| 1604 | } |
| 1605 | lighterCreateClient(signer, chainId, privateKey, apiKeyIndex, accountIndex) { |
| 1606 | const url = this.implodeHostname(this.urls['api']['public']); |
| 1607 | const res = globalThis.CreateClient(url, privateKey, chainId, apiKeyIndex, accountIndex); |
no test coverage detected