diff --git a/package-lock.json b/package-lock.json index a75f095d..5d2630ba 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,7 +11,7 @@ "dependencies": { "@hyperledger/cactus-test-tooling": "^2.0.0-rc.2", "@stellar/freighter-api": "^1.7.1", - "@stellar/stellar-sdk": "^11.2.2", + "@stellar/stellar-sdk": "^12.2.0", "axios": "^1.6.2", "uuid": "^9.0.1" }, @@ -44,7 +44,7 @@ "tsc-alias": "^1.8.8", "tsconfig-paths": "^4.2.0", "tslib": "^2.6.2", - "typescript": "^5.3.2" + "typescript": "^5.5.4" } }, "node_modules/@ampproject/remapping": { @@ -72,7 +72,7 @@ } }, "node_modules/@babel/compat-data": { - "version": "7.24.9", + "version": "7.25.2", "dev": true, "license": "MIT", "engines": { @@ -80,20 +80,20 @@ } }, "node_modules/@babel/core": { - "version": "7.24.9", + "version": "7.25.2", "dev": true, "license": "MIT", "dependencies": { "@ampproject/remapping": "^2.2.0", "@babel/code-frame": "^7.24.7", - "@babel/generator": "^7.24.9", - "@babel/helper-compilation-targets": "^7.24.8", - "@babel/helper-module-transforms": "^7.24.9", - "@babel/helpers": "^7.24.8", - "@babel/parser": "^7.24.8", - "@babel/template": "^7.24.7", - "@babel/traverse": "^7.24.8", - "@babel/types": "^7.24.9", + "@babel/generator": "^7.25.0", + "@babel/helper-compilation-targets": "^7.25.2", + "@babel/helper-module-transforms": "^7.25.2", + "@babel/helpers": "^7.25.0", + "@babel/parser": "^7.25.0", + "@babel/template": "^7.25.0", + "@babel/traverse": "^7.25.2", + "@babel/types": "^7.25.2", "convert-source-map": "^2.0.0", "debug": "^4.1.0", "gensync": "^1.0.0-beta.2", @@ -117,11 +117,11 @@ } }, "node_modules/@babel/generator": { - "version": "7.24.10", + "version": "7.25.0", "dev": true, "license": "MIT", "dependencies": { - "@babel/types": "^7.24.9", + "@babel/types": "^7.25.0", "@jridgewell/gen-mapping": "^0.3.5", "@jridgewell/trace-mapping": "^0.3.25", "jsesc": "^2.5.1" @@ -142,11 +142,11 @@ } }, "node_modules/@babel/helper-compilation-targets": { - "version": "7.24.8", + "version": "7.25.2", "dev": true, "license": "MIT", "dependencies": { - "@babel/compat-data": "^7.24.8", + "@babel/compat-data": "^7.25.2", "@babel/helper-validator-option": "^7.24.8", "browserslist": "^4.23.1", "lru-cache": "^5.1.1", @@ -164,40 +164,6 @@ "semver": "bin/semver.js" } }, - "node_modules/@babel/helper-environment-visitor": { - "version": "7.24.7", - "dev": true, - "license": "MIT", - "dependencies": { - "@babel/types": "^7.24.7" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-function-name": { - "version": "7.24.7", - "dev": true, - "license": "MIT", - "dependencies": { - "@babel/template": "^7.24.7", - "@babel/types": "^7.24.7" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-hoist-variables": { - "version": "7.24.7", - "dev": true, - "license": "MIT", - "dependencies": { - "@babel/types": "^7.24.7" - }, - "engines": { - "node": ">=6.9.0" - } - }, "node_modules/@babel/helper-module-imports": { "version": "7.24.7", "dev": true, @@ -211,15 +177,14 @@ } }, "node_modules/@babel/helper-module-transforms": { - "version": "7.24.9", + "version": "7.25.2", "dev": true, "license": "MIT", "dependencies": { - "@babel/helper-environment-visitor": "^7.24.7", "@babel/helper-module-imports": "^7.24.7", "@babel/helper-simple-access": "^7.24.7", - "@babel/helper-split-export-declaration": "^7.24.7", - "@babel/helper-validator-identifier": "^7.24.7" + "@babel/helper-validator-identifier": "^7.24.7", + "@babel/traverse": "^7.25.2" }, "engines": { "node": ">=6.9.0" @@ -248,17 +213,6 @@ "node": ">=6.9.0" } }, - "node_modules/@babel/helper-split-export-declaration": { - "version": "7.24.7", - "dev": true, - "license": "MIT", - "dependencies": { - "@babel/types": "^7.24.7" - }, - "engines": { - "node": ">=6.9.0" - } - }, "node_modules/@babel/helper-string-parser": { "version": "7.24.8", "dev": true, @@ -284,12 +238,12 @@ } }, "node_modules/@babel/helpers": { - "version": "7.24.8", + "version": "7.25.0", "dev": true, "license": "MIT", "dependencies": { - "@babel/template": "^7.24.7", - "@babel/types": "^7.24.8" + "@babel/template": "^7.25.0", + "@babel/types": "^7.25.0" }, "engines": { "node": ">=6.9.0" @@ -361,9 +315,12 @@ } }, "node_modules/@babel/parser": { - "version": "7.24.8", + "version": "7.25.3", "dev": true, "license": "MIT", + "dependencies": { + "@babel/types": "^7.25.2" + }, "bin": { "parser": "bin/babel-parser.js" }, @@ -535,31 +492,28 @@ } }, "node_modules/@babel/template": { - "version": "7.24.7", + "version": "7.25.0", "dev": true, "license": "MIT", "dependencies": { "@babel/code-frame": "^7.24.7", - "@babel/parser": "^7.24.7", - "@babel/types": "^7.24.7" + "@babel/parser": "^7.25.0", + "@babel/types": "^7.25.0" }, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/traverse": { - "version": "7.24.8", + "version": "7.25.3", "dev": true, "license": "MIT", "dependencies": { "@babel/code-frame": "^7.24.7", - "@babel/generator": "^7.24.8", - "@babel/helper-environment-visitor": "^7.24.7", - "@babel/helper-function-name": "^7.24.7", - "@babel/helper-hoist-variables": "^7.24.7", - "@babel/helper-split-export-declaration": "^7.24.7", - "@babel/parser": "^7.24.8", - "@babel/types": "^7.24.8", + "@babel/generator": "^7.25.0", + "@babel/parser": "^7.25.3", + "@babel/template": "^7.25.0", + "@babel/types": "^7.25.2", "debug": "^4.3.1", "globals": "^11.1.0" }, @@ -576,7 +530,7 @@ } }, "node_modules/@babel/types": { - "version": "7.24.9", + "version": "7.25.2", "dev": true, "license": "MIT", "dependencies": { @@ -2310,17 +2264,20 @@ }, "node_modules/@stellar/freighter-api": { "version": "1.7.1", - "license": "Apache-2.0" + "resolved": "https://registry.npmjs.org/@stellar/freighter-api/-/freighter-api-1.7.1.tgz", + "integrity": "sha512-XvPO+XgEbkeP0VhP0U1edOkds+rGS28+y8GRGbCVXeZ9ZslbWqRFQoETAdX8IXGuykk2ib/aPokiLc5ZaWYP7w==" }, "node_modules/@stellar/js-xdr": { "version": "3.1.2", - "license": "Apache-2.0" + "resolved": "https://registry.npmjs.org/@stellar/js-xdr/-/js-xdr-3.1.2.tgz", + "integrity": "sha512-VVolPL5goVEIsvuGqDc5uiKxV03lzfWdvYg1KikvwheDmTBO68CKDji3bAZ/kppZrx5iTA8z3Ld5yuytcvhvOQ==" }, "node_modules/@stellar/stellar-base": { - "version": "11.0.1", - "license": "Apache-2.0", + "version": "12.1.0", + "resolved": "https://registry.npmjs.org/@stellar/stellar-base/-/stellar-base-12.1.0.tgz", + "integrity": "sha512-pWwn+XWP5NotmIteZNuJzHeNn9DYSqH3lsYbtFUoSYy1QegzZdi9D8dK6fJ2fpBAnf/rcDjHgHOw3gtHaQFVbg==", "dependencies": { - "@stellar/js-xdr": "^3.1.1", + "@stellar/js-xdr": "^3.1.2", "base32.js": "^0.1.0", "bignumber.js": "^9.1.2", "buffer": "^6.0.3", @@ -2328,15 +2285,16 @@ "tweetnacl": "^1.0.3" }, "optionalDependencies": { - "sodium-native": "^4.0.10" + "sodium-native": "^4.1.1" } }, "node_modules/@stellar/stellar-sdk": { - "version": "11.3.0", - "license": "Apache-2.0", + "version": "12.2.0", + "resolved": "https://registry.npmjs.org/@stellar/stellar-sdk/-/stellar-sdk-12.2.0.tgz", + "integrity": "sha512-Wy5sDOqb5JvAC76f4sQIV6Pe3JNyZb0PuyVNjwt3/uWsjtxRkFk6s2yTHTefBLWoR+mKxDjO7QfzhycF1v8FXQ==", "dependencies": { - "@stellar/stellar-base": "^11.0.1", - "axios": "^1.6.8", + "@stellar/stellar-base": "^12.1.0", + "axios": "^1.7.2", "bignumber.js": "^9.1.2", "eventsource": "^2.0.2", "randombytes": "^2.1.0", @@ -2514,7 +2472,7 @@ } }, "node_modules/@types/node": { - "version": "20.14.11", + "version": "20.14.13", "license": "MIT", "dependencies": { "undici-types": "~5.26.4" @@ -2563,7 +2521,7 @@ } }, "node_modules/@types/ssh2/node_modules/@types/node": { - "version": "18.19.41", + "version": "18.19.42", "license": "MIT", "dependencies": { "undici-types": "~5.26.4" @@ -3872,7 +3830,7 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001643", + "version": "1.0.30001646", "dev": true, "funding": [ { @@ -4055,14 +4013,14 @@ } }, "node_modules/cli-cursor": { - "version": "4.0.0", + "version": "5.0.0", "dev": true, "license": "MIT", "dependencies": { - "restore-cursor": "^4.0.0" + "restore-cursor": "^5.0.0" }, "engines": { - "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + "node": ">=18" }, "funding": { "url": "https://github.com/sponsors/sindresorhus" @@ -4632,7 +4590,7 @@ } }, "node_modules/debug": { - "version": "4.3.5", + "version": "4.3.6", "license": "MIT", "dependencies": { "ms": "2.1.2" @@ -5045,7 +5003,7 @@ } }, "node_modules/electron-to-chromium": { - "version": "1.5.0", + "version": "1.5.4", "dev": true, "license": "ISC" }, @@ -5148,6 +5106,33 @@ "node": ">=10.0.0" } }, + "node_modules/engine.io/node_modules/ws": { + "version": "8.11.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.11.0.tgz", + "integrity": "sha512-HPG3wQd9sNQoT9xHyNCXoDUa+Xw/VevmY9FoHyQ+g+rrMn4j6FB4np7Z0OhdTgjx6MgQLK7jwSy1YecU1+4Asg==", + "engines": { + "node": ">=10.0.0" + }, + "peerDependencies": { + "bufferutil": "^4.0.1", + "utf-8-validate": "^5.0.2" + }, + "peerDependenciesMeta": { + "bufferutil": { + "optional": true + }, + "utf-8-validate": { + "optional": true + } + } + }, + "node_modules/engine.io-parser": { + "version": "5.0.7", + "license": "MIT", + "engines": { + "node": ">=10.0.0" + } + }, "node_modules/enhanced-resolve": { "version": "5.17.1", "dev": true, @@ -5178,6 +5163,17 @@ "node": ">=6" } }, + "node_modules/environment": { + "version": "1.1.0", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/error-ex": { "version": "1.3.2", "dev": true, @@ -6093,7 +6089,7 @@ } }, "node_modules/ethereum-bloom-filters": { - "version": "1.1.0", + "version": "1.2.0", "license": "MIT", "dependencies": { "@noble/hashes": "^1.4.0" @@ -6717,18 +6713,6 @@ "version": "1.0.0", "license": "ISC" }, - "node_modules/fsevents": { - "version": "2.3.3", - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": "^8.16.0 || ^10.6.0 || >=11.0.0" - } - }, "node_modules/function-bind": { "version": "1.1.2", "license": "MIT", @@ -9637,14 +9621,14 @@ } }, "node_modules/listr2": { - "version": "8.2.3", + "version": "8.2.4", "dev": true, "license": "MIT", "dependencies": { "cli-truncate": "^4.0.0", "colorette": "^2.0.20", "eventemitter3": "^5.0.1", - "log-update": "^6.0.0", + "log-update": "^6.1.0", "rfdc": "^1.4.1", "wrap-ansi": "^9.0.0" }, @@ -9725,13 +9709,13 @@ "license": "MIT" }, "node_modules/log-update": { - "version": "6.0.0", + "version": "6.1.0", "dev": true, "license": "MIT", "dependencies": { - "ansi-escapes": "^6.2.0", - "cli-cursor": "^4.0.0", - "slice-ansi": "^7.0.0", + "ansi-escapes": "^7.0.0", + "cli-cursor": "^5.0.0", + "slice-ansi": "^7.1.0", "strip-ansi": "^7.1.0", "wrap-ansi": "^9.0.0" }, @@ -9743,11 +9727,14 @@ } }, "node_modules/log-update/node_modules/ansi-escapes": { - "version": "6.2.1", + "version": "7.0.0", "dev": true, "license": "MIT", + "dependencies": { + "environment": "^1.0.0" + }, "engines": { - "node": ">=14.16" + "node": ">=18" }, "funding": { "url": "https://github.com/sponsors/sindresorhus" @@ -9990,6 +9977,17 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/mimic-function": { + "version": "5.0.1", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/mimic-response": { "version": "1.0.1", "license": "MIT", @@ -11263,6 +11261,18 @@ "node": ">= 6" } }, + "node_modules/pkcs11js": { + "version": "1.3.1", + "license": "MIT", + "optional": true, + "dependencies": { + "nan": "^2.15.0" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/PeculiarVentures" + } + }, "node_modules/pkg-dir": { "version": "4.2.0", "dev": true, @@ -11357,7 +11367,7 @@ } }, "node_modules/postcss": { - "version": "8.4.39", + "version": "8.4.40", "funding": [ { "type": "opencollective", @@ -11984,47 +11994,34 @@ } }, "node_modules/restore-cursor": { - "version": "4.0.0", + "version": "5.1.0", "dev": true, "license": "MIT", "dependencies": { - "onetime": "^5.1.0", - "signal-exit": "^3.0.2" + "onetime": "^7.0.0", + "signal-exit": "^4.1.0" }, "engines": { - "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + "node": ">=18" }, "funding": { "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/restore-cursor/node_modules/mimic-fn": { - "version": "2.1.0", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=6" - } - }, "node_modules/restore-cursor/node_modules/onetime": { - "version": "5.1.2", + "version": "7.0.0", "dev": true, "license": "MIT", "dependencies": { - "mimic-fn": "^2.1.0" + "mimic-function": "^5.0.0" }, "engines": { - "node": ">=6" + "node": ">=18" }, "funding": { "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/restore-cursor/node_modules/signal-exit": { - "version": "3.0.7", - "dev": true, - "license": "ISC" - }, "node_modules/retry": { "version": "0.13.1", "license": "MIT", @@ -13380,7 +13377,7 @@ } }, "node_modules/ts-jest": { - "version": "29.2.3", + "version": "29.2.4", "dev": true, "license": "MIT", "dependencies": { @@ -13777,11 +13774,14 @@ "license": "MIT" }, "node_modules/url": { - "version": "0.11.3", + "version": "0.11.4", "license": "MIT", "dependencies": { "punycode": "^1.4.1", - "qs": "^6.11.2" + "qs": "^6.12.3" + }, + "engines": { + "node": ">= 0.4" } }, "node_modules/url-join": { diff --git a/package.json b/package.json index 2a0548e8..642447d2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "stellar-plus", - "version": "0.10.2", + "version": "0.11.0", "description": "beta version of stellar-plus, an all-in-one sdk for the Stellar blockchain", "main": "./lib/index.js", "types": "./lib/index.d.ts", @@ -61,12 +61,12 @@ "tsc-alias": "^1.8.8", "tsconfig-paths": "^4.2.0", "tslib": "^2.6.2", - "typescript": "^5.3.2" + "typescript": "^5.5.4" }, "dependencies": { "@hyperledger/cactus-test-tooling": "^2.0.0-rc.2", "@stellar/freighter-api": "^1.7.1", - "@stellar/stellar-sdk": "^11.2.2", + "@stellar/stellar-sdk": "^12.2.0", "axios": "^1.6.2", "uuid": "^9.0.1" } diff --git a/src/stellar-plus/asset/classic/types.ts b/src/stellar-plus/asset/classic/types.ts index d7675da2..8b9f4de0 100644 --- a/src/stellar-plus/asset/classic/types.ts +++ b/src/stellar-plus/asset/classic/types.ts @@ -1,4 +1,4 @@ -import { HorizonApi } from '@stellar/stellar-sdk/lib/horizon' +import { Horizon } from '@stellar/stellar-sdk' import { AccountHandler } from 'stellar-plus/account/account-handler/types' import { AssetType, AssetTypes } from 'stellar-plus/asset/types' @@ -32,7 +32,7 @@ export type ClassicTokenInterfaceManagement = { to: string amount: number } & TransactionInvocation - ) => Promise + ) => Promise } export type ClassicTokenInterfaceUser = { @@ -47,5 +47,5 @@ export type ClassicTokenInterfaceUser = { export type ClassicUtils = { addTrustlineAndMint: ( args: { to: string; amount: number } & TransactionInvocation - ) => Promise + ) => Promise } diff --git a/src/stellar-plus/asset/soroban-token/constants.ts b/src/stellar-plus/asset/soroban-token/constants.ts index 08f45d0f..3932a281 100644 --- a/src/stellar-plus/asset/soroban-token/constants.ts +++ b/src/stellar-plus/asset/soroban-token/constants.ts @@ -1,6 +1,6 @@ -import { ContractSpec } from '@stellar/stellar-sdk' +import { Spec } from '@stellar/stellar-sdk/contract' -export const spec = new ContractSpec([ +export const spec = new Spec([ 'AAAAAAAAAAAAAAAKaW5pdGlhbGl6ZQAAAAAABAAAAAAAAAAFYWRtaW4AAAAAAAATAAAAAAAAAAdkZWNpbWFsAAAAAAQAAAAAAAAABG5hbWUAAAAQAAAAAAAAAAZzeW1ib2wAAAAAABAAAAAA', 'AAAAAAAAAAAAAAAEbWludAAAAAIAAAAAAAAAAnRvAAAAAAATAAAAAAAAAAZhbW91bnQAAAAAAAsAAAAA', 'AAAAAAAAAAAAAAAJc2V0X2FkbWluAAAAAAAAAQAAAAAAAAAJbmV3X2FkbWluAAAAAAAAEwAAAAA=', diff --git a/src/stellar-plus/asset/soroban-token/index.ts b/src/stellar-plus/asset/soroban-token/index.ts index 10dbbdbf..33f3e969 100644 --- a/src/stellar-plus/asset/soroban-token/index.ts +++ b/src/stellar-plus/asset/soroban-token/index.ts @@ -1,4 +1,5 @@ -import { Address, ContractSpec } from '@stellar/stellar-sdk' +import { Address } from '@stellar/stellar-sdk' +import { Spec } from '@stellar/stellar-sdk/contract' import { spec as defaultSpec, methods } from 'stellar-plus/asset/soroban-token/constants' import { SorobanTokenHandlerConstructorArgs, SorobanTokenInterface } from 'stellar-plus/asset/soroban-token/types' @@ -16,7 +17,7 @@ export class SorobanTokenHandler extends ContractEngine implements SorobanTokenI * @args args * @param {NetworkConfig} args.networkConfig - Network to connect to * @param args.contractParameters - Contract parameters - * @param {ContractSpec=} args.contractParameters.spec - Contract specification + * @param {Spec=} args.contractParameters.spec - Contract specification * @param {string=} args.contractParameters.contractId - Contract ID * @param {Buffer=} args.wasm - Contract WASM file as Buffer * @param {string=} args.wasmHash - Contract WASM hash identifier @@ -34,7 +35,7 @@ export class SorobanTokenHandler extends ContractEngine implements SorobanTokenI ...args, contractParameters: { ...args.contractParameters, - spec: args.contractParameters?.spec || (defaultSpec as ContractSpec), + spec: args.contractParameters?.spec || (defaultSpec as Spec), }, }) } diff --git a/src/stellar-plus/asset/soroban-token/index.unit.test.ts b/src/stellar-plus/asset/soroban-token/index.unit.test.ts index 726de623..86b51a68 100644 --- a/src/stellar-plus/asset/soroban-token/index.unit.test.ts +++ b/src/stellar-plus/asset/soroban-token/index.unit.test.ts @@ -1,6 +1,7 @@ /* eslint-disable @typescript-eslint/no-unsafe-assignment */ /* eslint-disable @typescript-eslint/no-explicit-any */ -import { Address, ContractSpec } from '@stellar/stellar-sdk' +import { Address } from '@stellar/stellar-sdk' +import { Spec } from '@stellar/stellar-sdk/contract' import { SorobanTokenHandler } from 'stellar-plus/asset/soroban-token' import { spec as DEFAULT_SPEC, methods } from 'stellar-plus/asset/soroban-token/constants' @@ -44,7 +45,7 @@ describe('SorobanToken', () => { }) it('should initialize with a custom spec', () => { - const mockedSpec = new ContractSpec(['AAAAAAAAAAAAAAAEbmFtZQAAAAAAAAABAAAAEA==']) + const mockedSpec = new Spec(['AAAAAAAAAAAAAAAEbmFtZQAAAAAAAAABAAAAEA==']) const token = new SorobanTokenHandler({ networkConfig: NETWORK_CONFIG, contractParameters: { diff --git a/src/stellar-plus/asset/soroban-token/types.ts b/src/stellar-plus/asset/soroban-token/types.ts index f16c2ed5..a5147276 100644 --- a/src/stellar-plus/asset/soroban-token/types.ts +++ b/src/stellar-plus/asset/soroban-token/types.ts @@ -1,4 +1,4 @@ -import { ContractSpec } from '@stellar/stellar-sdk' +import { Spec } from '@stellar/stellar-sdk/contract' import { AssetType } from 'stellar-plus/asset/types' import { Options } from 'stellar-plus/core/contract-engine/types' @@ -9,7 +9,7 @@ import { NetworkConfig, i128, u32 } from 'stellar-plus/types' export type SorobanTokenHandlerConstructorArgs = { networkConfig: NetworkConfig contractParameters?: { - spec?: ContractSpec + spec?: Spec contractId?: string wasm?: Buffer wasmHash?: string diff --git a/src/stellar-plus/asset/stellar-asset-contract/index.ts b/src/stellar-plus/asset/stellar-asset-contract/index.ts index 238683a0..09d73374 100644 --- a/src/stellar-plus/asset/stellar-asset-contract/index.ts +++ b/src/stellar-plus/asset/stellar-asset-contract/index.ts @@ -6,7 +6,6 @@ import { SorobanTokenHandler } from 'stellar-plus/asset/soroban-token' import { SorobanTokenHandlerConstructorArgs } from 'stellar-plus/asset/soroban-token/types' import { SACConstructorArgs, SACHandler as SACHandlerType } from 'stellar-plus/asset/stellar-asset-contract/types' import { AssetTypes } from 'stellar-plus/asset/types' - import { TransactionInvocation } from 'stellar-plus/core/types' export class SACHandler implements SACHandlerType { @@ -23,7 +22,7 @@ export class SACHandler implements SACHandlerType { * @param {string} args.code - The asset code. * @param {string | AccountHandler} args.issuerAccount - The issuer account. Can be a public key or an account handler. If it's an account handler, it will enable management functions. * @param contractParameters - The contract parameters. - * @param {ContractSpec=} contractParameters.spec - The contract specification object. + * @param {Spec=} contractParameters.spec - The contract specification object. * @param {Buffer=} contractParameters.wasm - The contract wasm file as a buffer. * @param {string=} contractParameters.wasmHash - The contract wasm hash id. * @param {string=} contractParameters.contractId - The contract id. diff --git a/src/stellar-plus/asset/stellar-asset-contract/types.ts b/src/stellar-plus/asset/stellar-asset-contract/types.ts index 874fabbb..675a0969 100644 --- a/src/stellar-plus/asset/stellar-asset-contract/types.ts +++ b/src/stellar-plus/asset/stellar-asset-contract/types.ts @@ -1,4 +1,4 @@ -import { ContractSpec } from '@stellar/stellar-sdk' +import { Spec } from '@stellar/stellar-sdk/contract' import { ClassicAssetHandler } from 'stellar-plus/asset/classic' import { ClassicAssetHandlerConstructorArgs } from 'stellar-plus/asset/classic/types' @@ -15,7 +15,7 @@ export type SACHandler = AssetType & { export type SACConstructorArgs = ClassicAssetHandlerConstructorArgs & { networkConfig: NetworkConfig contractParameters?: { - spec?: ContractSpec + spec?: Spec contractId?: string wasm?: Buffer wasmHash?: string diff --git a/src/stellar-plus/core/contract-engine/index.ts b/src/stellar-plus/core/contract-engine/index.ts index ea5555ca..9a8a6b1b 100644 --- a/src/stellar-plus/core/contract-engine/index.ts +++ b/src/stellar-plus/core/contract-engine/index.ts @@ -3,13 +3,13 @@ import { Buffer } from 'buffer' import { Address, Contract, - ContractSpec, Operation, OperationOptions, SorobanDataBuilder, SorobanRpc as SorobanRpcNamespace, xdr, } from '@stellar/stellar-sdk' +import { Spec } from '@stellar/stellar-sdk/contract' import { CEError } from 'stellar-plus/core/contract-engine/errors' import { @@ -44,7 +44,7 @@ import { ExtractInvocationOutputPlugin } from 'stellar-plus/utils/pipeline/plugi import { ExtractWasmHashPlugin } from 'stellar-plus/utils/pipeline/plugins/soroban-get-transaction/extract-wasm-hash' export class ContractEngine { - private spec?: ContractSpec + private spec?: Spec private contractId?: string private wasm?: Buffer private wasmHash?: string @@ -59,7 +59,7 @@ export class ContractEngine { * * @param {NetworkConfig} networkConfig - The network to use. * @param contractParameters - The contract parameters. - * @param {ContractSpec} contractParameters.spec - The contract specification object. + * @param {Spec} contractParameters.spec - The contract specification object. * @param {string=} contractParameters.contractId - The contract id. * @param {Buffer=} contractParameters.wasm - The contract wasm file as a buffer. * @param {string=} contractParameters.wasmHash - The contract wasm hash id. @@ -370,6 +370,7 @@ export class ContractEngine { } } finally { if (!isAssetAlreadyWrapped) { + // eslint-disable-next-line no-unsafe-finally throw CEError.failedToWrapAsset(error as StellarPlusError) } } diff --git a/src/stellar-plus/core/contract-engine/types.ts b/src/stellar-plus/core/contract-engine/types.ts index de2e26e4..6c8399db 100644 --- a/src/stellar-plus/core/contract-engine/types.ts +++ b/src/stellar-plus/core/contract-engine/types.ts @@ -1,4 +1,5 @@ -import { ContractSpec, SorobanDataBuilder, Asset as StellarAsset, xdr } from '@stellar/stellar-sdk' +import { SorobanDataBuilder, Asset as StellarAsset, xdr } from '@stellar/stellar-sdk' +import { Spec } from '@stellar/stellar-sdk/contract' import { AccountHandler } from 'stellar-plus/account' import { @@ -10,7 +11,7 @@ import { EnvelopeHeader, FeeBumpHeader, NetworkConfig, TransactionInvocation } f export type ContractEngineConstructorArgs = { networkConfig: NetworkConfig contractParameters: { - spec?: ContractSpec + spec?: Spec contractId?: string wasm?: Buffer wasmHash?: string diff --git a/src/stellar-plus/core/index.ts b/src/stellar-plus/core/index.ts index ee67c311..a69436a4 100644 --- a/src/stellar-plus/core/index.ts +++ b/src/stellar-plus/core/index.ts @@ -1,4 +1,4 @@ -import { ContractSpec } from '@stellar/stellar-sdk' +import { Spec } from '@stellar/stellar-sdk/contract' import { ContractEngine } from './contract-engine' import { BuildTransactionPipeline } from './pipelines/build-transaction' @@ -24,5 +24,6 @@ export const Core = { SubmitTransaction: SubmitTransactionPipeline, }, ContractEngine: ContractEngine, - ContractSpec, + // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment + Spec, } diff --git a/src/stellar-plus/core/pipelines/build-transaction/index.unit.test.ts b/src/stellar-plus/core/pipelines/build-transaction/index.unit.test.ts index 5b6e5b6a..b646b8b8 100644 --- a/src/stellar-plus/core/pipelines/build-transaction/index.unit.test.ts +++ b/src/stellar-plus/core/pipelines/build-transaction/index.unit.test.ts @@ -1,6 +1,5 @@ import { Asset, Operation } from '@stellar/stellar-base' import { Horizon, TransactionBuilder } from '@stellar/stellar-sdk' -import { AccountResponse } from '@stellar/stellar-sdk/lib/horizon' import { BuildTransactionPipelineInput as BTInput, @@ -32,7 +31,7 @@ jest.mock('@stellar/stellar-sdk', () => ({ export function createMockedHorizonHandler(): jest.Mocked { return { - loadAccount: jest.fn().mockResolvedValue({} as AccountResponse), + loadAccount: jest.fn().mockResolvedValue({} as Horizon.AccountResponse), server: new Horizon.Server(TestNet().horizonUrl as string), } } diff --git a/src/stellar-plus/core/pipelines/classic-transaction/types.ts b/src/stellar-plus/core/pipelines/classic-transaction/types.ts index a6e14cef..93cd41fb 100644 --- a/src/stellar-plus/core/pipelines/classic-transaction/types.ts +++ b/src/stellar-plus/core/pipelines/classic-transaction/types.ts @@ -1,5 +1,4 @@ -import { xdr } from '@stellar/stellar-sdk' -import { HorizonApi } from '@stellar/stellar-sdk/lib/horizon' +import { Horizon, xdr } from '@stellar/stellar-sdk' import { BuildTransactionPipelineOutput, @@ -38,7 +37,7 @@ export type ClassicTransactionPipelineInput = { export type ClassicTransactionPipelineOutput = | ClassicTransactionPipelineOutputSimple | ClassicTransactionPipelineOutputVerbose -export type ClassicTransactionPipelineOutputSimple = { response: HorizonApi.SubmitTransactionResponse } +export type ClassicTransactionPipelineOutputSimple = { response: Horizon.HorizonApi.SubmitTransactionResponse } export type ClassicTransactionPipelineOutputVerbose = (VerboseOutput | undefined) & { classicTransactionOutput: ClassicTransactionPipelineOutputSimple hash?: string diff --git a/src/stellar-plus/core/pipelines/soroban-auth/errors.ts b/src/stellar-plus/core/pipelines/soroban-auth/errors.ts index 59a60774..4e95e0f5 100644 --- a/src/stellar-plus/core/pipelines/soroban-auth/errors.ts +++ b/src/stellar-plus/core/pipelines/soroban-auth/errors.ts @@ -89,9 +89,25 @@ const couldntSimulateAuthorizedTransaction = ( }) } +const contractAuthNotSupported = ( + contractId: string, + conveyorBeltErrorMeta: ConveyorBeltErrorMeta +): StellarPlusError => { + return new StellarPlusError({ + code: ErrorCodesPipelineSorobanAuth.PSA004, + message: 'Contract authorization not supported!', + source: 'PipelineSorobanAuth', + details: `Contract authorization is not supported in the current version of Stellar Plus. This contract function is verifying against a specific contract authorization from (${contractId}) which is likely expected to be accessed as a sub-invocation instead of root invocation.`, + meta: { + conveyorBeltErrorMeta, + }, + }) +} + export const PSAError = { signerNotFound, noSignersProvided, couldntUpdateTransaction, couldntSimulateAuthorizedTransaction, + contractAuthNotSupported, } diff --git a/src/stellar-plus/core/pipelines/soroban-auth/index.ts b/src/stellar-plus/core/pipelines/soroban-auth/index.ts index 86b41e45..5a08de4f 100644 --- a/src/stellar-plus/core/pipelines/soroban-auth/index.ts +++ b/src/stellar-plus/core/pipelines/soroban-auth/index.ts @@ -58,9 +58,7 @@ export class SorobanAuthPipeline extends ConveyorBelt< ? [...additionalSignedSorobanAuth] : [] for (const authEntry of authEntriesToSign) { - const requiredSigner = Address.account( - authEntry.credentials().address().address().accountId().ed25519() - ).toString() + const requiredSigner = this.getRequiredSigner(authEntry, item, itemId) const signer = signers.find((s) => s.getPublicKey() === requiredSigner) as AccountHandler @@ -198,4 +196,19 @@ export class SorobanAuthPipeline extends ConveyorBelt< }) : [] } + + protected getRequiredSigner( + authEntry: xdr.SorobanAuthorizationEntry, + item: SorobanAuthPipelineInput, + itemId: string + ): string { + if (authEntry.credentials().address().address().switch().name === 'scAddressTypeContract') { + throw PSAError.contractAuthNotSupported( + Address.contract(authEntry.credentials().address().address().contractId()).toString(), + extractConveyorBeltErrorMeta(item, this.getMeta(itemId)) + ) + } + + return Address.account(authEntry.credentials().address().address().accountId().ed25519()).toString() + } } diff --git a/src/stellar-plus/core/pipelines/submit-transaction/errors.ts b/src/stellar-plus/core/pipelines/submit-transaction/errors.ts index bd56fba4..13fef8b2 100644 --- a/src/stellar-plus/core/pipelines/submit-transaction/errors.ts +++ b/src/stellar-plus/core/pipelines/submit-transaction/errors.ts @@ -1,4 +1,4 @@ -import { HorizonApi } from '@stellar/stellar-sdk/lib/horizon' +import { Horizon } from '@stellar/stellar-sdk' import { StellarPlusError } from 'stellar-plus/error' import { ConveyorBeltErrorMeta } from 'stellar-plus/error/helpers/conveyor-belt' @@ -54,7 +54,7 @@ const horizonSubmissionFailed = ( }) } const transactionSubmittedThroughHorizonFailed = ( - response: HorizonApi.SubmitTransactionResponse, + response: Horizon.HorizonApi.SubmitTransactionResponse, conveyorBeltErrorMeta: ConveyorBeltErrorMeta, transaction: Transaction | FeeBumpTransaction ): StellarPlusError => { diff --git a/src/stellar-plus/core/pipelines/submit-transaction/index.ts b/src/stellar-plus/core/pipelines/submit-transaction/index.ts index 1c6bde70..f11c6caa 100644 --- a/src/stellar-plus/core/pipelines/submit-transaction/index.ts +++ b/src/stellar-plus/core/pipelines/submit-transaction/index.ts @@ -1,5 +1,4 @@ -import { FeeBumpTransaction, SorobanRpc, Transaction } from '@stellar/stellar-sdk' -import { HorizonApi } from '@stellar/stellar-sdk/lib/horizon' +import { FeeBumpTransaction, Horizon, SorobanRpc, Transaction } from '@stellar/stellar-sdk' import { SubmitTransactionPipelineInput, @@ -38,7 +37,7 @@ export class SubmitTransactionPipeline extends ConveyorBelt< // =================== // if (networkHandler instanceof HorizonHandlerClient) { - let response: HorizonApi.SubmitTransactionResponse + let response: Horizon.HorizonApi.SubmitTransactionResponse try { response = await this.submitTransactionThroughHorizon(transaction, networkHandler) } catch (error) { @@ -87,10 +86,10 @@ export class SubmitTransactionPipeline extends ConveyorBelt< private async submitTransactionThroughHorizon( transaction: Transaction | FeeBumpTransaction, horizonHandler: HorizonHandlerClient - ): Promise { + ): Promise { const response = (await horizonHandler.server.submitTransaction(transaction, { skipMemoRequiredCheck: true, // Not skipping memo required check causes an error when submitting fee bump transactions - })) as HorizonApi.SubmitTransactionResponse + })) as Horizon.HorizonApi.SubmitTransactionResponse return response } diff --git a/src/stellar-plus/core/pipelines/submit-transaction/types.ts b/src/stellar-plus/core/pipelines/submit-transaction/types.ts index 1f07f420..9e6e5352 100644 --- a/src/stellar-plus/core/pipelines/submit-transaction/types.ts +++ b/src/stellar-plus/core/pipelines/submit-transaction/types.ts @@ -1,5 +1,4 @@ -import { FeeBumpTransaction, SorobanRpc, Transaction } from '@stellar/stellar-sdk' -import { HorizonApi } from '@stellar/stellar-sdk/lib/horizon' +import { FeeBumpTransaction, Horizon, SorobanRpc, Transaction } from '@stellar/stellar-sdk' import { HorizonHandler } from 'stellar-plus' import { RpcHandler } from 'stellar-plus/rpc/types' @@ -11,7 +10,7 @@ export type SubmitTransactionPipelineInput = { } export type SubmitTransactionPipelineOutput = { - response: HorizonApi.SubmitTransactionResponse | SorobanRpc.Api.SendTransactionResponse + response: Horizon.HorizonApi.SubmitTransactionResponse | SorobanRpc.Api.SendTransactionResponse } export enum SubmitTransactionPipelineType { diff --git a/src/stellar-plus/core/spec.ts b/src/stellar-plus/core/spec.ts new file mode 100644 index 00000000..60cd3504 --- /dev/null +++ b/src/stellar-plus/core/spec.ts @@ -0,0 +1,7 @@ +// import { contract } from '@stellar/stellar-sdk' + +// const SpecClass = [contract.Spec] +// export type Spec = (typeof SpecClass)[0] + +// // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment +// export default { SpecClass: SpecClass[0] } diff --git a/src/stellar-plus/error/helpers/horizon.ts b/src/stellar-plus/error/helpers/horizon.ts index 53889940..1a41d4bd 100644 --- a/src/stellar-plus/error/helpers/horizon.ts +++ b/src/stellar-plus/error/helpers/horizon.ts @@ -1,5 +1,4 @@ -import { FeeBumpTransaction, Transaction } from '@stellar/stellar-sdk' -import { HorizonApi } from '@stellar/stellar-sdk/lib/horizon' +import { FeeBumpTransaction, Horizon, Transaction } from '@stellar/stellar-sdk' import { AxiosError } from 'axios' import { extractAxiosErrorInfo } from './axios' @@ -7,7 +6,7 @@ import { operationErrorMessages, operationSpecificErrorMessages, transactionErro import { OperationData, extractOperationsData, extractTransactionData } from './transaction' import { Meta } from '../types' export const extractDataFromSubmitTransactionError = ( - response: HorizonApi.SubmitTransactionResponse + response: Horizon.HorizonApi.SubmitTransactionResponse ): SubmitTransactionMetaInfo => { return { ...response, @@ -39,10 +38,10 @@ export const diagnoseSubmitError = ( const axiosError = extractAxiosErrorInfo(error) if (axiosError.data && isHorizonErrorResponseData(axiosError.data)) { - const horizonError = axiosError.data as HorizonApi.ErrorResponseData + const horizonError = axiosError.data as Horizon.HorizonApi.ErrorResponseData const diagnostic = horizonError.status === 400 // Failed transaction, contains error codes - ? reviewTransactionError(horizonError as HorizonApi.ErrorResponseData.TransactionFailed, tx) + ? reviewTransactionError(horizonError as Horizon.HorizonApi.ErrorResponseData.TransactionFailed, tx) : undefined return { @@ -50,7 +49,7 @@ export const diagnoseSubmitError = ( diagnostic, meta: { transactionData, - data: axiosError.data as HorizonApi.ErrorResponseData, + data: axiosError.data as Horizon.HorizonApi.ErrorResponseData, }, } as HorizonDiagnostics } @@ -60,7 +59,7 @@ export const diagnoseSubmitError = ( meta: { message: axiosError.message, transactionData, - data: axiosError.data as HorizonApi.ErrorResponseData, + data: axiosError.data as Horizon.HorizonApi.ErrorResponseData, }, } } @@ -72,7 +71,7 @@ export const diagnoseSubmitError = ( const isHorizonErrorResponseData = (data: unknown): boolean => { if (typeof data === 'object' && data !== null) { - const potentialError = data as HorizonApi.ErrorResponseData.Base // Type assertion + const potentialError = data as Horizon.HorizonApi.ErrorResponseData.Base // Type assertion return ( 'status' in potentialError && 'title' in potentialError && 'type' in potentialError && 'detail' in potentialError ) @@ -93,7 +92,7 @@ export type DiagnosticEntry = { } const reviewTransactionError = ( - errorData: HorizonApi.ErrorResponseData.TransactionFailed, + errorData: Horizon.HorizonApi.ErrorResponseData.TransactionFailed, tx?: Transaction | FeeBumpTransaction ): TransactionDiagnostic => { const diagnostic: TransactionDiagnostic = {} diff --git a/src/stellar-plus/soroban/contracts/certificate-of-deposit/constants.ts b/src/stellar-plus/soroban/contracts/certificate-of-deposit/constants.ts index 055d2550..0d2e5d7f 100644 --- a/src/stellar-plus/soroban/contracts/certificate-of-deposit/constants.ts +++ b/src/stellar-plus/soroban/contracts/certificate-of-deposit/constants.ts @@ -1,4 +1,5 @@ -import { ContractSpec } from '@stellar/stellar-sdk' +import { Spec } from '@stellar/stellar-sdk/contract' + export enum Methods { deposit = 'deposit', withdraw = 'withdraw', @@ -10,7 +11,7 @@ export enum Methods { initialize = 'initialize', } -export const spec = new ContractSpec([ +export const spec = new Spec([ 'AAAAAAAAAAAAAAAKaW5pdGlhbGl6ZQAAAAAACAAAAAAAAAAFYWRtaW4AAAAAAAATAAAAAAAAAAVhc3NldAAAAAAAABMAAAAAAAAABHRlcm0AAAAGAAAAAAAAAA1jb21wb3VuZF9zdGVwAAAAAAAABgAAAAAAAAAKeWllbGRfcmF0ZQAAAAAABgAAAAAAAAALbWluX2RlcG9zaXQAAAAACwAAAAAAAAAMcGVuYWx0eV9yYXRlAAAABgAAAAAAAAAQYWxsb3dhbmNlX3BlcmlvZAAAAAQAAAAA', 'AAAAAAAAAAAAAAAHZGVwb3NpdAAAAAACAAAAAAAAAAZhbW91bnQAAAAAAAsAAAAAAAAAB2FkZHJlc3MAAAAAEwAAAAA=', 'AAAAAAAAAAAAAAAId2l0aGRyYXcAAAACAAAAAAAAAAdhZGRyZXNzAAAAABMAAAAAAAAAGWFjY2VwdF9wcmVtYXR1cmVfd2l0aGRyYXcAAAAAAAABAAAAAA==', diff --git a/src/stellar-plus/soroban/contracts/certificate-of-deposit/index.ts b/src/stellar-plus/soroban/contracts/certificate-of-deposit/index.ts index d04de527..a31558e3 100644 --- a/src/stellar-plus/soroban/contracts/certificate-of-deposit/index.ts +++ b/src/stellar-plus/soroban/contracts/certificate-of-deposit/index.ts @@ -1,4 +1,5 @@ -import { Address, ContractSpec } from '@stellar/stellar-sdk' +import { Address } from '@stellar/stellar-sdk' +import { Spec } from '@stellar/stellar-sdk/contract' import { ContractEngine } from 'stellar-plus/core/contract-engine' import { ContractEngineConstructorArgs } from 'stellar-plus/core/contract-engine/types' @@ -30,7 +31,7 @@ export class CertificateOfDepositClient extends ContractEngine implements Certif * */ constructor(args: CertificateOfDepositContractConstructorArgs) { - const contractSpec = args.contractParameters.spec || (spec as ContractSpec) + const contractSpec = args.contractParameters.spec || (spec as Spec) const contractParameters = { ...args.contractParameters, spec: contractSpec, diff --git a/src/stellar-plus/soroban/contracts/certificate-of-deposit/types.ts b/src/stellar-plus/soroban/contracts/certificate-of-deposit/types.ts index 43a9b5f0..0f25ea5b 100644 --- a/src/stellar-plus/soroban/contracts/certificate-of-deposit/types.ts +++ b/src/stellar-plus/soroban/contracts/certificate-of-deposit/types.ts @@ -1,4 +1,4 @@ -import { ContractSpec } from '@stellar/stellar-sdk' +import { Spec } from '@stellar/stellar-sdk/contract' import { Options } from 'stellar-plus/core/contract-engine/types' import { TransactionInvocation } from 'stellar-plus/core/types' @@ -21,7 +21,7 @@ export type CertificateOfDepositContract = { export type CertificateOfDepositContractConstructorArgs = { networkConfig: NetworkConfig contractParameters: { - spec?: ContractSpec + spec?: Spec contractId?: string wasm?: Buffer wasmHash?: string diff --git a/src/stellar-plus/types.ts b/src/stellar-plus/types.ts index e39d6375..e4122e83 100644 --- a/src/stellar-plus/types.ts +++ b/src/stellar-plus/types.ts @@ -1,9 +1,9 @@ import { Address as StellarAddress, - ContractSpec as _ContractSpec, FeeBumpTransaction as _FeeBumpTransaction, Transaction as _Transaction, } from '@stellar/stellar-sdk' +import { Spec as _Spec } from '@stellar/stellar-sdk/contract' import { EnvelopeHeader as _EnvelopeHeader, @@ -37,6 +37,6 @@ export type Address = StellarAddress | string export type TransactionInvocation = _TransactionInvocation export type EnvelopeHeader = _EnvelopeHeader export type FeeBumpHeader = _FeeBumpHeader -export type ContractSpec = _ContractSpec +export type Spec = _Spec export * as Errors from 'stellar-plus/error/types' diff --git a/src/stellar-plus/utils/pipeline/plugins/simulate-transaction/extract-invocation-output/index.ts b/src/stellar-plus/utils/pipeline/plugins/simulate-transaction/extract-invocation-output/index.ts index c2dd7c04..6a69c3b2 100644 --- a/src/stellar-plus/utils/pipeline/plugins/simulate-transaction/extract-invocation-output/index.ts +++ b/src/stellar-plus/utils/pipeline/plugins/simulate-transaction/extract-invocation-output/index.ts @@ -1,4 +1,4 @@ -import { ContractSpec } from '@stellar/stellar-sdk' +import { Spec } from '@stellar/stellar-sdk/contract' import { SimulateTransactionPipelineInput, @@ -18,10 +18,10 @@ export class ExtractInvocationOutputFromSimulationPlugin { readonly type = SimulateTransactionPipelineType.id readonly name: string = 'ExtractContractIdPlugin' - private spec: ContractSpec + private spec: Spec private method: string - constructor(spec: ContractSpec, method: string) { + constructor(spec: Spec, method: string) { this.spec = spec this.method = method } diff --git a/src/stellar-plus/utils/pipeline/plugins/soroban-get-transaction/extract-invocation-output/index.ts b/src/stellar-plus/utils/pipeline/plugins/soroban-get-transaction/extract-invocation-output/index.ts index 35f051a1..03f68fbc 100644 --- a/src/stellar-plus/utils/pipeline/plugins/soroban-get-transaction/extract-invocation-output/index.ts +++ b/src/stellar-plus/utils/pipeline/plugins/soroban-get-transaction/extract-invocation-output/index.ts @@ -1,4 +1,4 @@ -import { ContractSpec } from '@stellar/stellar-sdk' +import { Spec } from '@stellar/stellar-sdk/contract' import { ContractInvocationOutput, @@ -18,10 +18,10 @@ export class ExtractInvocationOutputPlugin { readonly type = SorobanGetTransactionPipelineType.id readonly name: string = 'ExtractInvocationOutputPlugin' - private spec: ContractSpec + private spec: Spec private method: string - constructor(spec: ContractSpec, method: string) { + constructor(spec: Spec, method: string) { this.spec = spec this.method = method } diff --git a/src/tests/integration/classic-asset-management/index.integration.test.ts b/src/tests/integration/classic-asset-management/index.integration.test.ts index e80e2730..f3b283a7 100644 --- a/src/tests/integration/classic-asset-management/index.integration.test.ts +++ b/src/tests/integration/classic-asset-management/index.integration.test.ts @@ -1,13 +1,7 @@ -import { ContractSpec } from '@stellar/stellar-sdk' -import { sign } from 'crypto' import { DefaultAccountHandler } from 'stellar-plus/account' import { ClassicAssetHandler } from 'stellar-plus/asset' -import { ContractEngine } from 'stellar-plus/core/contract-engine' -import { SignatureThreshold } from 'stellar-plus/core/types' - import { CustomNet, NetworkConfig } from 'stellar-plus/network' import { StellarTestLedger, TestLedgerNetwork } from 'stellar-plus/test/stellar-test-ledger' -import { TransactionInvocation } from 'stellar-plus/types' import { simpleTxInvocation } from 'tests/utils' describe('Classic Asset Management Use Case: ', () => { diff --git a/src/tests/integration/classic-asset-wrapping/index.integration.test.ts b/src/tests/integration/classic-asset-wrapping/index.integration.test.ts index 0d1978b7..9b9f6eee 100644 --- a/src/tests/integration/classic-asset-wrapping/index.integration.test.ts +++ b/src/tests/integration/classic-asset-wrapping/index.integration.test.ts @@ -1,15 +1,7 @@ -import { ContractSpec } from '@stellar/stellar-sdk' -import exp from 'constants' -import { sign } from 'crypto' import { DefaultAccountHandler } from 'stellar-plus/account' -import { ClassicAssetHandler, SACHandler } from 'stellar-plus/asset' -import { SACAssetHandler } from 'stellar-plus/asset/types' -import { ContractEngine } from 'stellar-plus/core/contract-engine' -import { SignatureThreshold } from 'stellar-plus/core/types' - +import { SACHandler } from 'stellar-plus/asset' import { CustomNet, NetworkConfig } from 'stellar-plus/network' import { StellarTestLedger, TestLedgerNetwork } from 'stellar-plus/test/stellar-test-ledger' -import { TransactionInvocation } from 'stellar-plus/types' import { contractIdRegex } from 'stellar-plus/utils/regex' import { simpleTxInvocation } from 'tests/utils' diff --git a/src/tests/integration/hello-world-contract/index.integration.test.ts b/src/tests/integration/hello-world-contract/index.integration.test.ts index a4de8b25..d3af4edb 100644 --- a/src/tests/integration/hello-world-contract/index.integration.test.ts +++ b/src/tests/integration/hello-world-contract/index.integration.test.ts @@ -1,7 +1,7 @@ -import { ContractSpec } from '@stellar/stellar-sdk' +import { Spec } from '@stellar/stellar-sdk/contract' + import { DefaultAccountHandler } from 'stellar-plus/account' import { ContractEngine } from 'stellar-plus/core/contract-engine' - import { CustomNet, NetworkConfig } from 'stellar-plus/network' import { StellarTestLedger, TestLedgerNetwork } from 'stellar-plus/test/stellar-test-ledger' import { TransactionInvocation } from 'stellar-plus/types' @@ -16,7 +16,7 @@ describe('Hello World Contract Use Case: ', () => { network: TestLedgerNetwork.LOCAL, }) - let helloWorldSpec: ContractSpec + let helloWorldSpec: Spec let networkConfig: NetworkConfig let wasmBuffer: Buffer beforeAll(async () => { @@ -33,7 +33,7 @@ describe('Hello World Contract Use Case: ', () => { wasmBuffer = await loadWasmFile('./src/tests/contracts/hello-world/hello_world.wasm') expect(wasmBuffer).toBeDefined() - helloWorldSpec = new ContractSpec(spec) + helloWorldSpec = new Spec(spec) }) afterAll(async () => { diff --git a/src/tests/integration/profiler-plugin/index.integration.test.ts b/src/tests/integration/profiler-plugin/index.integration.test.ts index ced4bc36..6cd79833 100644 --- a/src/tests/integration/profiler-plugin/index.integration.test.ts +++ b/src/tests/integration/profiler-plugin/index.integration.test.ts @@ -1,20 +1,10 @@ -import { ContractSpec } from '@stellar/stellar-sdk' import { DefaultAccountHandler } from 'stellar-plus/account' -import { ClassicAssetHandler, SACHandler } from 'stellar-plus/asset' -import { SACAssetHandler } from 'stellar-plus/asset/types' -import { ContractEngine } from 'stellar-plus/core/contract-engine' -import { SorobanTransactionPipelinePlugin } from 'stellar-plus/core/pipelines/soroban-transaction/types' - +import { SACHandler } from 'stellar-plus/asset' import { CustomNet, NetworkConfig } from 'stellar-plus/network' import { StellarTestLedger, TestLedgerNetwork } from 'stellar-plus/test/stellar-test-ledger' -import { TransactionInvocation } from 'stellar-plus/types' -import { GenericPlugin } from 'stellar-plus/utils/pipeline/conveyor-belts/types' -import { DebugPlugin } from 'stellar-plus/utils/pipeline/plugins/generic' import { ProfilerPlugin } from 'stellar-plus/utils/pipeline/plugins/soroban-transaction' import { LogEntry } from 'stellar-plus/utils/profiler/profiling-handler/types' -import { contractIdRegex, wasmHashRegex } from 'stellar-plus/utils/regex' -import { GetNameArgs, GetNameResponse, methods, spec } from 'tests/contracts/hello-world/spec' -import { loadWasmFile, simpleTxInvocation } from 'tests/utils' +import { simpleTxInvocation } from 'tests/utils' describe('Profiler Plugin Use Case: ', () => { const logLevel = 'TRACE' diff --git a/tsconfig.json b/tsconfig.json index 72a7dd7a..3f6c7972 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,9 +2,9 @@ "compilerOptions": { "target": "es2016", "lib": ["es6"], - "module": "commonjs", + "module": "Node16", "rootDir": "./src", - "moduleResolution": "node10", + "moduleResolution": "Node16", "baseUrl": "./src", "resolveJsonModule": true, "allowJs": true, @@ -15,10 +15,14 @@ "importHelpers": true, "esModuleInterop": true, "forceConsistentCasingInFileNames": true, + "allowSyntheticDefaultImports": true, "strict": true, "noImplicitAny": true, "skipLibCheck": true }, "exclude": ["commitlint.config.js"], - "include": ["./src"] + "include": ["./src"], + "paths": { + "@stellar/stellar-sdk/contract": ["node_modules/@stellar/stellar-sdk/lib/contract/index"] + } }