Skip to content

Commit

Permalink
Merge pull request #210 from ElrondNetwork/improvements-05-08
Browse files Browse the repository at this point in the history
Minor improvements / fixes
  • Loading branch information
andreibancioiu authored May 9, 2022
2 parents 403944b + a2a5ada commit 3ad4cb6
Show file tree
Hide file tree
Showing 15 changed files with 191 additions and 92 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/erdjs-publish-alpha-beta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 12
node-version: 16
registry-url: https://registry.npmjs.org/

- name: Create release
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/erdjs-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 12
node-version: 16
registry-url: https://registry.npmjs.org/

- name: Create release
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/erdjs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:

strategy:
matrix:
node-version: [12.x]
node-version: [16.x]

steps:
- uses: actions/checkout@v2
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how
## Unreleased
- TBD

## 10.2.3
- [Minor improvements and fixes](https://github.com/ElrondNetwork/elrond-sdk-erdjs/pull/210)

## 10.2.2
- [Decoupling, minor refactoring](https://github.com/ElrondNetwork/elrond-sdk-erdjs/pull/209)

Expand Down
136 changes: 86 additions & 50 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@elrondnetwork/erdjs",
"version": "10.2.2",
"version": "10.2.3",
"description": "Smart Contracts interaction framework",
"main": "out/index.js",
"types": "out/index.d.js",
Expand Down
14 changes: 14 additions & 0 deletions src/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,20 @@ export interface ITransactionFetcher {
getTransaction(txHash: string): Promise<ITransactionOnNetwork>;
}

export interface IPlainTransactionObject {
nonce: number;
value: string;
receiver: string;
sender: string;
gasPrice: number;
gasLimit: number;
data?: string;
chainID: string;
version: number;
options?: number;
signature?: string;
}

export interface ISignature { hex(): string; }
export interface IAddress { bech32(): string; }
export interface ITransactionValue { toString(): string; }
Expand Down
4 changes: 4 additions & 0 deletions src/smartcontracts/code.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,8 @@ export class Code {
toString(): string {
return this.hex;
}

valueOf(): Buffer {
return Buffer.from(this.hex, "hex");
}
}
12 changes: 11 additions & 1 deletion src/smartcontracts/interaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export class Interaction {
private gasPrice: IGasPrice | undefined = undefined;
private chainID: IChainID = "";
private querent: IAddress = new Address();
private explicitReceiver?: IAddress;

private isWithSingleESDTTransfer: boolean = false;
private isWithSingleESDTNFTTransfer: boolean = false;
Expand Down Expand Up @@ -81,8 +82,12 @@ export class Interaction {
return this.gasLimit;
}

getExplicitReceiver(): IAddress | undefined {
return this.explicitReceiver;
}

buildTransaction(): Transaction {
let receiver = this.contract.getAddress();
let receiver = this.explicitReceiver || this.contract.getAddress();
let func: ContractFunction = this.function;
let args = this.args;

Expand Down Expand Up @@ -185,6 +190,11 @@ export class Interaction {
return this;
}

withExplicitReceiver(receiver: IAddress): Interaction {
this.explicitReceiver = receiver;
return this;
}

/**
* To perform custom checking, extend {@link Interaction} and override this method.
*/
Expand Down
Loading

0 comments on commit 3ad4cb6

Please sign in to comment.