diff --git a/package-lock.json b/package-lock.json index ed8f99c..6df9a07 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "stellar-plus", - "version": "0.12.0", + "version": "0.12.4", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "stellar-plus", - "version": "0.12.0", + "version": "0.12.4", "license": "ISC", "dependencies": { "@hyperledger/cactus-test-tooling": "^2.0.0-rc.2", diff --git a/package.json b/package.json index 3728b30..d39dbce 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "stellar-plus", - "version": "0.12.3", + "version": "0.12.4", "description": "beta version of stellar-plus, an all-in-one sdk for the Stellar blockchain", "main": "./lib/index.js", "types": "./lib/index.d.ts", diff --git a/src/stellar-plus/asset/soroban-token/index.ts b/src/stellar-plus/asset/soroban-token/index.ts index 33f3e96..e62cff2 100644 --- a/src/stellar-plus/asset/soroban-token/index.ts +++ b/src/stellar-plus/asset/soroban-token/index.ts @@ -1,4 +1,3 @@ -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' @@ -61,7 +60,7 @@ export class SorobanTokenHandler extends ContractEngine implements SorobanTokenI return (await this.invokeContract({ method: methods.initialize, methodArgs: { - admin: new Address(args.admin), + admin: args.admin, decimal: args.decimal, name: args.name, symbol: args.symbol, @@ -98,8 +97,8 @@ export class SorobanTokenHandler extends ContractEngine implements SorobanTokenI return (await this.invokeContract({ method: methods.set_admin, methodArgs: { - id: new Address(args.id), - new_admin: new Address(args.new_admin), + id: args.id, + new_admin: args.new_admin, }, signers: args.signers, header: args.header, @@ -147,7 +146,7 @@ export class SorobanTokenHandler extends ContractEngine implements SorobanTokenI return (await this.invokeContract({ method: methods.set_authorized, methodArgs: { - id: new Address(args.id), + id: args.id, authorize: args.authorize, }, signers: args.signers, @@ -178,7 +177,7 @@ export class SorobanTokenHandler extends ContractEngine implements SorobanTokenI return (await this.invokeContract({ method: methods.mint, methodArgs: { - to: new Address(args.to), + to: args.to, amount: args.amount, }, signers: args.signers, @@ -209,7 +208,7 @@ export class SorobanTokenHandler extends ContractEngine implements SorobanTokenI return (await this.invokeContract({ method: methods.clawback, methodArgs: { - from: new Address(args.from), + from: args.from, amount: args.amount, }, signers: args.signers, @@ -242,8 +241,8 @@ export class SorobanTokenHandler extends ContractEngine implements SorobanTokenI return (await this.readFromContract({ method: methods.allowance, methodArgs: { - from: new Address(args.from), - spender: new Address(args.spender), + from: args.from, + spender: args.spender, }, header: args.header, })) as i128 @@ -271,8 +270,8 @@ export class SorobanTokenHandler extends ContractEngine implements SorobanTokenI return (await this.invokeContract({ method: methods.approve, methodArgs: { - from: new Address(args.from), - spender: new Address(args.spender), + from: args.from, + spender: args.spender, amount: args.amount, expiration_ledger: args.expiration_ledger, }, @@ -297,7 +296,7 @@ export class SorobanTokenHandler extends ContractEngine implements SorobanTokenI return (await this.readFromContract({ method: methods.balance, methodArgs: { - id: new Address(args.id), + id: args.id, }, header: args.header, })) as i128 @@ -318,7 +317,7 @@ export class SorobanTokenHandler extends ContractEngine implements SorobanTokenI return (await this.readFromContract({ method: methods.spendable_balance, methodArgs: { - id: new Address(args.id), + id: args.id, }, header: args.header, })) as i128 @@ -345,8 +344,8 @@ export class SorobanTokenHandler extends ContractEngine implements SorobanTokenI return (await this.invokeContract({ method: methods.transfer, methodArgs: { - from: new Address(args.from), - to: new Address(args.to), + from: args.from, + to: args.to, amount: args.amount, }, signers: args.signers, @@ -377,9 +376,9 @@ export class SorobanTokenHandler extends ContractEngine implements SorobanTokenI return (await this.invokeContract({ method: methods.transfer_from, methodArgs: { - spender: new Address(args.spender), - from: new Address(args.from), - to: new Address(args.to), + spender: args.spender, + from: args.from, + to: args.to, amount: args.amount, }, signers: args.signers, @@ -408,7 +407,7 @@ export class SorobanTokenHandler extends ContractEngine implements SorobanTokenI return (await this.invokeContract({ method: methods.burn, methodArgs: { - from: new Address(args.from), + from: args.from, amount: args.amount, }, signers: args.signers, @@ -438,8 +437,8 @@ export class SorobanTokenHandler extends ContractEngine implements SorobanTokenI return (await this.invokeContract({ method: methods.burn_from, methodArgs: { - spender: new Address(args.spender), - from: new Address(args.from), + spender: args.spender, + from: args.from, amount: args.amount, }, signers: args.signers, 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 86b51a6..0e20120 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,5 @@ /* eslint-disable @typescript-eslint/no-unsafe-assignment */ /* eslint-disable @typescript-eslint/no-explicit-any */ -import { Address } from '@stellar/stellar-sdk' import { Spec } from '@stellar/stellar-sdk/contract' import { SorobanTokenHandler } from 'stellar-plus/asset/soroban-token' @@ -129,7 +128,7 @@ describe('SorobanToken', () => { expect(invokeSpy).toHaveBeenCalledExactlyOnceWith({ method: methods.initialize, - methodArgs: { ...initializeArgs, admin: new Address(initializeArgs.admin) }, + methodArgs: { ...initializeArgs, admin: initializeArgs.admin }, ...MOCKED_TX_INVOCATION, }) }) @@ -146,7 +145,7 @@ describe('SorobanToken', () => { expect(invokeSpy).toHaveBeenCalledExactlyOnceWith({ method: methods.set_admin, - methodArgs: { id: new Address(currentAdmin), new_admin: new Address(newAdmin) }, + methodArgs: { id: currentAdmin, new_admin: newAdmin }, ...MOCKED_TX_INVOCATION, }) }) @@ -164,7 +163,7 @@ describe('SorobanToken', () => { expect(invokeSpy).toHaveBeenCalledExactlyOnceWith({ method: methods.set_authorized, - methodArgs: { ...setAuthorizedArgs, id: new Address(accountToAuthorize) }, + methodArgs: { ...setAuthorizedArgs, id: accountToAuthorize }, ...MOCKED_TX_INVOCATION, }) }) @@ -180,7 +179,7 @@ describe('SorobanToken', () => { expect(invokeSpy).toHaveBeenCalledExactlyOnceWith({ method: methods.mint, - methodArgs: { ...mintArgs, to: new Address(recipient) }, + methodArgs: { ...mintArgs, to: recipient }, ...MOCKED_TX_INVOCATION, }) }) @@ -196,7 +195,7 @@ describe('SorobanToken', () => { expect(invokeSpy).toHaveBeenCalledExactlyOnceWith({ method: methods.burn, - methodArgs: { ...burnArgs, from: new Address(from) }, + methodArgs: { ...burnArgs, from: from }, ...MOCKED_TX_INVOCATION, }) }) @@ -214,7 +213,7 @@ describe('SorobanToken', () => { expect(invokeSpy).toHaveBeenCalledExactlyOnceWith({ method: methods.clawback, - methodArgs: { ...clawbackArgs, from: new Address(targetAccount) }, + methodArgs: { ...clawbackArgs, from: targetAccount }, ...MOCKED_TX_INVOCATION, }) }) @@ -233,7 +232,7 @@ describe('SorobanToken', () => { expect(invokeSpy).toHaveBeenCalledExactlyOnceWith({ method: methods.approve, - methodArgs: { ...approveArgs, from: new Address(from), spender: new Address(spender) }, + methodArgs: { ...approveArgs, from: from, spender: spender }, ...MOCKED_TX_INVOCATION, }) }) @@ -251,7 +250,7 @@ describe('SorobanToken', () => { expect(invokeSpy).toHaveBeenCalledExactlyOnceWith({ method: methods.transfer, - methodArgs: { ...transferArgs, from: new Address(from), to: new Address(to) }, + methodArgs: { ...transferArgs, from: from, to: to }, ...MOCKED_TX_INVOCATION, }) }) @@ -271,7 +270,7 @@ describe('SorobanToken', () => { expect(invokeSpy).toHaveBeenCalledExactlyOnceWith({ method: methods.transfer_from, - methodArgs: { ...transferArgs, from: new Address(from), to: new Address(to), spender: new Address(spender) }, + methodArgs: { ...transferArgs, from: from, to: to, spender: spender }, ...MOCKED_TX_INVOCATION, }) }) @@ -291,7 +290,7 @@ describe('SorobanToken', () => { expect(invokeSpy).toHaveBeenCalledExactlyOnceWith({ method: methods.burn_from, - methodArgs: { ...burnFromArgs, from: new Address(from), spender: new Address(spender) }, + methodArgs: { ...burnFromArgs, from: from, spender: spender }, ...MOCKED_TX_INVOCATION, }) }) @@ -375,7 +374,7 @@ describe('SorobanToken', () => { expect(readSpy).toHaveBeenCalledExactlyOnceWith({ method: methods.balance, - methodArgs: { id: new Address(balanceArgs.id) }, + methodArgs: { id: balanceArgs.id }, header: MOCKED_TX_INVOCATION.header, }) }) @@ -391,7 +390,7 @@ describe('SorobanToken', () => { expect(readSpy).toHaveBeenCalledExactlyOnceWith({ method: methods.spendable_balance, - methodArgs: { id: new Address(spendableBalanceArgs.id) }, + methodArgs: { id: spendableBalanceArgs.id }, header: MOCKED_TX_INVOCATION.header, }) }) @@ -406,7 +405,7 @@ describe('SorobanToken', () => { expect(readSpy).toHaveBeenCalledExactlyOnceWith({ method: methods.allowance, - methodArgs: { from: new Address(allowanceArgs.from), spender: new Address(allowanceArgs.spender) }, + methodArgs: { from: allowanceArgs.from, spender: allowanceArgs.spender }, header: MOCKED_TX_INVOCATION.header, }) }) 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 a31558e..4647a50 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,3 @@ -import { Address } from '@stellar/stellar-sdk' import { Spec } from '@stellar/stellar-sdk/contract' import { ContractEngine } from 'stellar-plus/core/contract-engine' @@ -60,7 +59,7 @@ export class CertificateOfDepositClient extends ContractEngine implements Certif */ public async deposit(args: DepositArgs): Promise { const amount = args.amount as i128 - const address = new Address(args.address) + const address = args.address await this.invokeContract({ method: this.methods.deposit, @@ -83,7 +82,7 @@ export class CertificateOfDepositClient extends ContractEngine implements Certif * */ public async withdraw(args: WithdrawArgs): Promise { - const address = new Address(args.address) + const address = args.address const accept_premature_withdraw = args.acceptPrematureWithdraw as boolean await this.invokeContract({ @@ -103,7 +102,7 @@ export class CertificateOfDepositClient extends ContractEngine implements Certif * @description - Gets the current estimated yield accrued for the account's position so far. */ public async getEstimatedYield(args: GetEstimatedYieldArgs): Promise { - const address = new Address(args.address) + const address = args.address const result: i128 = (await this.readFromContract({ method: this.methods.getEstimatedYield, @@ -123,7 +122,7 @@ export class CertificateOfDepositClient extends ContractEngine implements Certif * @description - Gets the current open position for the account. */ public async getPosition(args: GetPositionArgs): Promise { - const address = new Address(args.address) + const address = args.address const result: i128 = (await this.readFromContract({ method: this.methods.getPosition, @@ -142,7 +141,7 @@ export class CertificateOfDepositClient extends ContractEngine implements Certif * @description - Gets the current estimated premature withdraw for the account. This is the amount that will be received if the account withdraws prematurely, with the penalty applied. */ public async getEstimatedPrematureWithdraw(args: GetEstimatedPrematureWithdrawArgs): Promise { - const address = new Address(args.address) + const address = args.address const result: i128 = (await this.readFromContract({ method: this.methods.getEstimatedPrematureWithdraw, @@ -162,7 +161,7 @@ export class CertificateOfDepositClient extends ContractEngine implements Certif * @description - Gets the current time left for the account. This is the time left until the account can withdraw without penalty. */ public async getTimeLeft(args: GetTimeLeftArgs): Promise { - const address = new Address(args.address) + const address = args.address const result: u64 = (await this.readFromContract({ method: this.methods.getTimeLeft, @@ -196,8 +195,8 @@ export class CertificateOfDepositClient extends ContractEngine implements Certif */ public async initialize(args: Initialize): Promise { const { term, compoundStep, yieldRate, minDeposit, penaltyRate } = args - const admin = new Address(args.admin) - const asset = new Address(args.asset) + const admin = args.admin + const asset = args.asset await this.invokeContract({ method: this.methods.initialize,