Skip to content

Commit

Permalink
Merge pull request #518 from multiversx/MergeMainInFeat
Browse files Browse the repository at this point in the history
Merge main in feat
  • Loading branch information
danielailie authored Oct 21, 2024
2 parents 778ae19 + ced12ce commit 78b94b3
Show file tree
Hide file tree
Showing 12 changed files with 0 additions and 331 deletions.
8 changes: 0 additions & 8 deletions src/converters/transactionsConverter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@ export class TransactionsConverter {
guardian: transaction.guardian ? transaction.guardian : undefined,
signature: this.toHexOrUndefined(transaction.signature),
guardianSignature: this.toHexOrUndefined(transaction.guardianSignature),
relayer: transaction.relayer ? transaction.relayer : undefined,
innerTransactions: transaction.innerTransactions.length
? transaction.innerTransactions.map((tx) => this.transactionToPlainObject(tx))
: undefined,
};

return plainObject;
Expand Down Expand Up @@ -62,10 +58,6 @@ export class TransactionsConverter {
options: Number(object.options),
signature: this.bufferFromHex(object.signature),
guardianSignature: this.bufferFromHex(object.guardianSignature),
relayer: object.relayer,
innerTransactions: object.innerTransactions
? object.innerTransactions.map((tx) => this.plainObjectToTransaction(tx))
: undefined,
});

return transaction;
Expand Down
79 changes: 0 additions & 79 deletions src/converters/transactionsConverters.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,85 +59,6 @@ describe("test transactions converter", async () => {
guardian: undefined,
signature: undefined,
guardianSignature: undefined,
relayer: undefined,
innerTransactions: undefined,
});
});

it("converts relayedV3 transaction to plain object and back", () => {
const converter = new TransactionsConverter();

const innerTx = new Transaction({
nonce: 90,
value: BigInt("123456789000000000000000000000"),
sender: "erd1qyu5wthldzr8wx5c9ucg8kjagg0jfs53s8nr3zpz3hypefsdd8ssycr6th",
receiver: "erd1spyavw0956vq68xj8y4tenjpq2wd5a9p2c6j8gsz7ztyrnpxrruqzu66jx",
senderUsername: "alice",
receiverUsername: "bob",
gasPrice: 1000000000,
gasLimit: 80000,
data: Buffer.from("hello"),
chainID: "localnet",
version: 2,
relayer: "erd1k2s324ww2g0yj38qn2ch2jwctdy8mnfxep94q9arncc6xecg3xaq6mjse8",
});

const relayedTx = new Transaction({
nonce: 77,
value: BigInt("0"),
sender: "erd1k2s324ww2g0yj38qn2ch2jwctdy8mnfxep94q9arncc6xecg3xaq6mjse8",
receiver: "erd1k2s324ww2g0yj38qn2ch2jwctdy8mnfxep94q9arncc6xecg3xaq6mjse8",
gasPrice: 1000000000,
gasLimit: 50000,
chainID: "localnet",
version: 2,
innerTransactions: [innerTx],
});

const plainObject = converter.transactionToPlainObject(relayedTx);
const restoredTransaction = converter.plainObjectToTransaction(plainObject);

assert.deepEqual(plainObject, relayedTx.toPlainObject());
assert.deepEqual(restoredTransaction, Transaction.fromPlainObject(plainObject));
assert.deepEqual(restoredTransaction, relayedTx);
assert.deepEqual(plainObject, {
nonce: 77,
value: "0",
sender: "erd1k2s324ww2g0yj38qn2ch2jwctdy8mnfxep94q9arncc6xecg3xaq6mjse8",
receiver: "erd1k2s324ww2g0yj38qn2ch2jwctdy8mnfxep94q9arncc6xecg3xaq6mjse8",
senderUsername: undefined,
receiverUsername: undefined,
gasPrice: 1000000000,
gasLimit: 50000,
data: undefined,
chainID: "localnet",
version: 2,
options: undefined,
guardian: undefined,
signature: undefined,
guardianSignature: undefined,
relayer: undefined,
innerTransactions: [
{
nonce: 90,
value: "123456789000000000000000000000",
sender: "erd1qyu5wthldzr8wx5c9ucg8kjagg0jfs53s8nr3zpz3hypefsdd8ssycr6th",
receiver: "erd1spyavw0956vq68xj8y4tenjpq2wd5a9p2c6j8gsz7ztyrnpxrruqzu66jx",
senderUsername: "YWxpY2U=",
receiverUsername: "Ym9i",
gasPrice: 1000000000,
gasLimit: 80000,
data: "aGVsbG8=",
chainID: "localnet",
version: 2,
options: undefined,
guardian: undefined,
signature: undefined,
guardianSignature: undefined,
relayer: "erd1k2s324ww2g0yj38qn2ch2jwctdy8mnfxep94q9arncc6xecg3xaq6mjse8",
innerTransactions: undefined,
},
],
});
});

Expand Down
4 changes: 0 additions & 4 deletions src/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ export interface IPlainTransactionObject {
options?: number;
signature?: string;
guardianSignature?: string;
relayer?: string;
innerTransactions?: IPlainTransactionObject[];
}

export interface ISignature {
Expand Down Expand Up @@ -106,6 +104,4 @@ export interface ITransaction {
guardian: string;
signature: Uint8Array;
guardianSignature: Uint8Array;
relayer: string;
innerTransactions: ITransaction[];
}
2 changes: 0 additions & 2 deletions src/networkProviders/providers.dev.net.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -452,8 +452,6 @@ describe("test network providers on devnet: Proxy and API", function () {
guardian: "",
guardianSignature: new Uint8Array(),
options: 0,
relayer: "",
innerTransactions: [],
};

const apiLegacyTxHash = await apiProvider.sendTransaction(transaction);
Expand Down
77 changes: 0 additions & 77 deletions src/proto/compiled.js

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

39 changes: 0 additions & 39 deletions src/proto/serializer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { TokenTransfer } from "../tokens";
import { Transaction } from "../transaction";
import { TransactionPayload } from "../transactionPayload";
import { ProtoSerializer } from "./serializer";
import { TransactionComputer } from "../transactionComputer";

describe("serialize transactions", () => {
let wallets: Record<string, TestWallet>;
Expand Down Expand Up @@ -146,42 +145,4 @@ describe("serialize transactions", () => {
"08cc011209000de0b6b3a76400001a200139472eff6886771a982f3083da5d421f24c29181e63888228dc81ca60d69e12205616c6963652a20b2a11555ce521e4944e09ab17549d85b487dcd26c84b5017a39e31a3670889ba32056361726f6c388094ebdc0340d086035201545802624051e6cd78fb3ab4b53ff7ad6864df27cb4a56d70603332869d47a5cf6ea977c30e696103e41e8dddf2582996ad335229fdf4acb726564dbc1a0bc9e705b511f06",
);
});

it("serialize with inner transactions", async () => {
const innerTransaction = new Transaction({
nonce: 204,
value: "1000000000000000000",
sender: Address.fromBech32("erd1k2s324ww2g0yj38qn2ch2jwctdy8mnfxep94q9arncc6xecg3xaq6mjse8"),
receiver: Address.fromBech32("erd1qyu5wthldzr8wx5c9ucg8kjagg0jfs53s8nr3zpz3hypefsdd8ssycr6th"),
senderUsername: "carol",
receiverUsername: "alice",
gasLimit: 50000,
chainID: "T",
});

const signer = wallets.carol.signer;
const txComputer = new TransactionComputer();
innerTransaction.signature = await signer.sign(txComputer.computeBytesForSigning(innerTransaction));

const relayedTransaction = new Transaction({
nonce: 204,
value: "1000000000000000000",
sender: Address.fromBech32("erd1k2s324ww2g0yj38qn2ch2jwctdy8mnfxep94q9arncc6xecg3xaq6mjse8"),
receiver: Address.fromBech32("erd1qyu5wthldzr8wx5c9ucg8kjagg0jfs53s8nr3zpz3hypefsdd8ssycr6th"),
senderUsername: "carol",
receiverUsername: "alice",
gasLimit: 50000,
chainID: "T",
relayer: wallets["carol"].address.toBech32(),
innerTransactions: [innerTransaction],
});

relayedTransaction.signature = await signer.sign(txComputer.computeBytesForSigning(relayedTransaction));

const serializedTransaction = serializer.serializeTransaction(relayedTransaction);
assert.equal(
serializedTransaction.toString("hex"),
"08cc011209000de0b6b3a76400001a200139472eff6886771a982f3083da5d421f24c29181e63888228dc81ca60d69e12205616c6963652a20b2a11555ce521e4944e09ab17549d85b487dcd26c84b5017a39e31a3670889ba32056361726f6c388094ebdc0340d0860352015458026240901a6a974d6ab36546e7881c6e0364ec4c61a891aa70e5eb60f818d6c92a39cfa0beac6fab73f503853cfe8fe6149b4be207ddb93788f8450d75a07fa8759d06820120b2a11555ce521e4944e09ab17549d85b487dcd26c84b5017a39e31a3670889ba8a01b10108cc011209000de0b6b3a76400001a200139472eff6886771a982f3083da5d421f24c29181e63888228dc81ca60d69e12205616c6963652a20b2a11555ce521e4944e09ab17549d85b487dcd26c84b5017a39e31a3670889ba32056361726f6c388094ebdc0340d086035201545802624051e6cd78fb3ab4b53ff7ad6864df27cb4a56d70603332869d47a5cf6ea977c30e696103e41e8dddf2582996ad335229fdf4acb726564dbc1a0bc9e705b511f06",
);
});
});
6 changes: 0 additions & 6 deletions src/proto/serializer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,6 @@ export class ProtoSerializer {
protoTransaction.GuardianSignature = transaction.guardianSignature;
}

if (transaction.relayer) {
protoTransaction.Relayer = new Address(transaction.relayer).getPublicKey();
}

protoTransaction.InnerTransactions = transaction.innerTransactions.map((tx) => this.convertToProtoMessage(tx));

return protoTransaction;
}

Expand Down
2 changes: 0 additions & 2 deletions src/proto/transaction.proto
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,4 @@ message Transaction {
uint32 Options = 13;
bytes GuardianAddr = 14;
bytes GuardianSignature = 15;
bytes Relayer = 16;
repeated Transaction InnerTransactions = 17;
}
15 changes: 0 additions & 15 deletions src/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,16 +102,6 @@ export class Transaction {
*/
public guardianSignature: Uint8Array;

/**
* The relayer in case it is a relayedV3 Transaction.
*/
public relayer: string;

/**
* The inner transactions in case it is a relayedV3 Transaction.
*/
public innerTransactions: ITransaction[];

/**
* Creates a new Transaction object.
*/
Expand All @@ -131,8 +121,6 @@ export class Transaction {
guardian?: IAddress | string;
signature?: Uint8Array;
guardianSignature?: Uint8Array;
relayer?: string;
innerTransactions?: ITransaction[];
}) {
this.nonce = BigInt(options.nonce?.valueOf() || 0n);
// We still rely on "bigNumber" for value, because client code might be passing a BigNumber object as a legacy "ITransactionValue",
Expand All @@ -152,9 +140,6 @@ export class Transaction {

this.signature = options.signature || Buffer.from([]);
this.guardianSignature = options.guardianSignature || Buffer.from([]);

this.relayer = options.relayer || "";
this.innerTransactions = options.innerTransactions || [];
}

private addressAsBech32(address: IAddress | string): string {
Expand Down
4 changes: 0 additions & 4 deletions src/transactionComputer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,6 @@ export class TransactionComputer {
obj.version = transaction.version;
obj.options = transaction.options ? transaction.options : undefined;
obj.guardian = transaction.guardian ? transaction.guardian : undefined;
obj.relayer = transaction.relayer ? transaction.relayer : undefined;
obj.innerTransactions = transaction.innerTransactions.length
? transaction.innerTransactions.map((tx) => this.toPlainObject(tx, true))
: undefined;

return obj;
}
Expand Down
Loading

0 comments on commit 78b94b3

Please sign in to comment.