From 91f2c1e0ffb897b954df39440f6adc5b5483431a Mon Sep 17 00:00:00 2001 From: Luiz Felipe Bolsoni Gomes Date: Tue, 16 Aug 2022 17:40:42 -0300 Subject: [PATCH 01/17] feat: upgrade to fuel-core 0.10.1 --- .../call-test-contract.test.ts | 1 - .../src/__test__/contract-factory.test.ts | 46 +++--- .../contract/src/__test__/contract.test.ts | 20 +-- .../src/contracts/contract-factory.ts | 1 - .../functions/base-invocation-scope.ts | 4 +- packages/contract/src/types.ts | 2 - packages/predicate/src/predicate.ts | 2 +- packages/providers/codegen.json | 1 - packages/providers/fuel-core-schema.graphql | 135 +++++++++++++++--- packages/providers/src/operations.graphql | 2 +- packages/providers/src/provider.test.ts | 20 ++- packages/providers/src/provider.ts | 27 ++-- .../transaction-request.ts | 17 +-- packages/testcases/src/sendTransaction.json | 1 - packages/testcases/src/signTransaction.json | 1 - packages/transactions/src/coders/input.ts | 13 +- .../src/coders/transaction.test.ts | 2 - .../transactions/src/coders/transaction.ts | 39 ++--- packages/transactions/src/consts.ts | 5 +- packages/wallet/src/test-utils.ts | 1 - packages/wallet/src/transfer.test.ts | 1 - packages/wallet/src/wallet.ts | 2 +- services/fuel-core/Dockerfile | 7 +- 23 files changed, 211 insertions(+), 139 deletions(-) diff --git a/packages/contract/src/__test__/call-test-contract/call-test-contract.test.ts b/packages/contract/src/__test__/call-test-contract/call-test-contract.test.ts index 7d84ea52f37..fa93082a73a 100644 --- a/packages/contract/src/__test__/call-test-contract/call-test-contract.test.ts +++ b/packages/contract/src/__test__/call-test-contract/call-test-contract.test.ts @@ -19,7 +19,6 @@ const deployContract = async (factory: ContractFactory, useCache: boolean = true if (!useCache) { return factory.deployContract({ gasPrice: 1, - bytePrice: 1, }); } contractInstance = await factory.deployContract(); diff --git a/packages/contract/src/__test__/contract-factory.test.ts b/packages/contract/src/__test__/contract-factory.test.ts index 8a24a864909..777a4ecbec1 100644 --- a/packages/contract/src/__test__/contract-factory.test.ts +++ b/packages/contract/src/__test__/contract-factory.test.ts @@ -124,36 +124,38 @@ describe('Contract Factory', () => { expect(vB256).toEqual(b256); }); - it('Creates a contract with initial storage. Both dynamic key and fixed vars', async () => { + it.only('Creates a contract with initial storage. Both dynamic key and fixed vars', async () => { const factory = await createContractFactory(); const b256 = '0x626f0c36909faecc316056fca8be684ab0cd06afc63247dc008bdf9e433f927a'; - const contract = await factory.deployContract({ - storageSlots: [ - ...storageSlots, // initializing from storage_slots.json - { key: '0000000000000000000000000000000000000000000000000000000000000001', value: b256 }, // Initializing manual value - ], - }); + expect(true); - const { value: var1 } = await contract.functions.return_var1().call(); - expect(var1).toEqual(10n); + // const contract = await factory.deployContract({ + // storageSlots: [ + // ...storageSlots, // initializing from storage_slots.json + // { key: '0000000000000000000000000000000000000000000000000000000000000001', value: b256 }, // Initializing manual value + // ], + // }); - const { value: var2 } = await contract.functions.return_var2().call(); - expect(var2).toEqual(20); + // const { value: var1 } = await contract.functions.return_var1().call(); + // expect(var1).toEqual(10n); - const { value: var3 } = await contract.functions.return_var3().call(); - expect(var3).toEqual(30); + // const { value: var2 } = await contract.functions.return_var2().call(); + // expect(var2).toEqual(20); - const { value: var4 } = await contract.functions.return_var4().call(); - expect(var4).toEqual(true); + // const { value: var3 } = await contract.functions.return_var3().call(); + // expect(var3).toEqual(30); - const { value: var5 } = await contract.functions.return_var5().call(); - expect(var5).toEqual({ - v1: true, - v2: 50n, - }); + // const { value: var4 } = await contract.functions.return_var4().call(); + // expect(var4).toEqual(true); - const { value: vB256 } = await contract.functions.return_b256().get(); - expect(vB256).toEqual(b256); + // const { value: var5 } = await contract.functions.return_var5().call(); + // expect(var5).toEqual({ + // v1: true, + // v2: 50n, + // }); + + // const { value: vB256 } = await contract.functions.return_b256().get(); + // expect(vB256).toEqual(b256); }); }); diff --git a/packages/contract/src/__test__/contract.test.ts b/packages/contract/src/__test__/contract.test.ts index ca206e5fde3..bc69bf89c55 100644 --- a/packages/contract/src/__test__/contract.test.ts +++ b/packages/contract/src/__test__/contract.test.ts @@ -237,7 +237,6 @@ describe('Contract', () => { }) .txParams({ gasPrice: 1, - bytePrice: 1, gasLimit: 2000000, }) .call(); @@ -261,7 +260,6 @@ describe('Contract', () => { ]) .txParams({ gasPrice: 1, - bytePrice: 1, gasLimit: 2000000, }) .call<[bigint, bigint, string]>(); @@ -285,7 +283,6 @@ describe('Contract', () => { ]) .txParams({ gasPrice: 1, - bytePrice: 1, gasLimit: 100, }) .call<[bigint, bigint, string]>(); @@ -310,7 +307,6 @@ describe('Contract', () => { ]) .txParams({ gasPrice: 1, - bytePrice: 1, gasLimit: 1_000_000, }) .call<[bigint, bigint]>(); @@ -338,14 +334,12 @@ describe('Contract', () => { ]); const transactionCost = await invocationScope.getTransactionCost(); - expect(transactionCost.bytePrice).toBe(0n); expect(transactionCost.gasPrice).toBe(0n); expect(transactionCost.fee).toBeGreaterThanOrEqual(0n); expect(transactionCost.gasUsed).toBeGreaterThan(1000n); const { value } = await invocationScope .txParams({ - bytePrice: transactionCost.bytePrice, gasPrice: transactionCost.gasPrice, gasLimit: transactionCost.gasUsed, }) @@ -354,7 +348,7 @@ describe('Contract', () => { expect(value).toEqual([100n, 200n]); }); - it('Get transaction cost with bytePrice and gasPrice 1', async () => { + it('Get transaction cost with gasPrice 1', async () => { const contract = await setup(); const invocationScope = contract @@ -368,13 +362,11 @@ describe('Contract', () => { ]) .txParams({ gasPrice: 1, - bytePrice: 1, }); - // Get transaction cost using bytePrice and gasPrice from + // Get transaction cost using gasPrice from // invocation scope const transactionCost = await invocationScope.getTransactionCost(); - expect(transactionCost.bytePrice).toBe(1n); expect(transactionCost.gasPrice).toBe(1n); expect(transactionCost.fee).toBeGreaterThanOrEqual(2n); expect(transactionCost.gasUsed).toBeGreaterThan(1000n); @@ -383,7 +375,6 @@ describe('Contract', () => { // and can be used as gasLimit const { value } = await invocationScope .txParams({ - bytePrice: transactionCost.bytePrice, gasPrice: transactionCost.gasPrice, gasLimit: transactionCost.gasUsed, }) @@ -392,7 +383,7 @@ describe('Contract', () => { expect(value).toEqual([100n, 200n]); }); - it('Get transaction cost with bytePrice and gasPrice 2', async () => { + it('Get transaction cost with gasPrice 2', async () => { const contract = await setup(); const invocationScope = contract.multiCall([ @@ -403,14 +394,12 @@ describe('Contract', () => { forward: [200, AltToken], }), ]); - // Get transaction cost using bytePrice and gasPrice + // Get transaction cost using gasPrice // override by SDK user const transactionCost = await invocationScope.getTransactionCost({ gasPrice: 2, - bytePrice: 2, }); - expect(transactionCost.bytePrice).toBe(2n); expect(transactionCost.gasPrice).toBe(2n); expect(transactionCost.fee).toBeGreaterThanOrEqual(4n); expect(transactionCost.gasUsed).toBeGreaterThan(1000n); @@ -419,7 +408,6 @@ describe('Contract', () => { // and can be used as gasLimit const { value } = await invocationScope .txParams({ - bytePrice: transactionCost.bytePrice, gasPrice: transactionCost.gasPrice, gasLimit: transactionCost.gasUsed, }) diff --git a/packages/contract/src/contracts/contract-factory.ts b/packages/contract/src/contracts/contract-factory.ts index b3a8134a943..8a58fc85ba7 100644 --- a/packages/contract/src/contracts/contract-factory.ts +++ b/packages/contract/src/contracts/contract-factory.ts @@ -81,7 +81,6 @@ export default class ContractFactory { const request = new CreateTransactionRequest({ gasPrice: 0, gasLimit: MAX_GAS_PER_TX, - bytePrice: 0, bytecodeWitnessIndex: 0, witnesses: [this.bytecode], ...options, diff --git a/packages/contract/src/contracts/functions/base-invocation-scope.ts b/packages/contract/src/contracts/functions/base-invocation-scope.ts index 6ac4b1c004f..00590eaa037 100644 --- a/packages/contract/src/contracts/functions/base-invocation-scope.ts +++ b/packages/contract/src/contracts/functions/base-invocation-scope.ts @@ -137,7 +137,7 @@ export class BaseInvocationScope { /** * Run a valid transaction in dryRun mode and returns useful details about - * gasUsed, gasPrice, bytePrice and transaction estimate fee in native coins. + * gasUsed, gasPrice and transaction estimate fee in native coins. */ async getTransactionCost(options?: TransactionCostOptions) { const provider = (this.contract.wallet?.provider || this.contract.provider) as Provider; @@ -146,7 +146,6 @@ export class BaseInvocationScope { await this.prepareTransaction(options); const request = transactionRequestify(this.transactionRequest); request.gasPrice = BigInt(request.gasPrice || options?.gasPrice || 0); - request.bytePrice = BigInt(request.bytePrice || options?.bytePrice || 0); const txCost = await provider.getTransactionCost(request, options?.tolerance); return txCost; @@ -173,7 +172,6 @@ export class BaseInvocationScope { request.gasLimit = toBigInt(txParams.gasLimit || request.gasLimit); request.gasPrice = toBigInt(txParams.gasPrice || request.gasPrice); - request.bytePrice = toBigInt(txParams.bytePrice || request.bytePrice); request.addVariableOutputs(this.txParameters?.variableOutputs || 0); return this; diff --git a/packages/contract/src/types.ts b/packages/contract/src/types.ts index d89764fb9c2..edf574a0052 100644 --- a/packages/contract/src/types.ts +++ b/packages/contract/src/types.ts @@ -11,7 +11,6 @@ export type CallParams = Partial<{ }>; export type TxParams = Partial<{ - bytePrice: BigNumberish; gasPrice: BigNumberish; gasLimit: BigNumberish; variableOutputs: number; @@ -45,7 +44,6 @@ export type InvocationScopeLike = { export type TransactionCostOptions = Partial<{ fundTransaction: boolean; - bytePrice: BigNumberish; gasPrice: BigNumberish; tolerance: number; }>; diff --git a/packages/predicate/src/predicate.ts b/packages/predicate/src/predicate.ts index 0c5f1859d01..531eabe7b82 100644 --- a/packages/predicate/src/predicate.ts +++ b/packages/predicate/src/predicate.ts @@ -17,7 +17,7 @@ import type { Wallet } from '@fuel-ts/wallet'; type BuildPredicateOptions = { fundTransaction?: boolean; -} & Pick; +} & Pick; export class Predicate { bytes: Uint8Array; diff --git a/packages/providers/codegen.json b/packages/providers/codegen.json index d7d72984110..324502ec0a7 100644 --- a/packages/providers/codegen.json +++ b/packages/providers/codegen.json @@ -10,7 +10,6 @@ { "typescript-graphql-request": {} } ], "config": { - "strictScalars": true, "scalars": { "DateTime": "string", "HexString": "string", diff --git a/packages/providers/fuel-core-schema.graphql b/packages/providers/fuel-core-schema.graphql index 2e10e70ba91..b02c9fb8966 100644 --- a/packages/providers/fuel-core-schema.graphql +++ b/packages/providers/fuel-core-schema.graphql @@ -18,6 +18,11 @@ type BalanceConnection { A list of edges. """ edges: [BalanceEdge!]! + + """ + A list of nodes. + """ + nodes: [Balance!]! } """ @@ -30,7 +35,7 @@ type BalanceEdge { cursor: String! """ - "The item at the end of the edge + The item at the end of the edge """ node: Balance! } @@ -60,6 +65,11 @@ type BlockConnection { A list of edges. """ edges: [BlockEdge!]! + + """ + A list of nodes. + """ + nodes: [Block!]! } """ @@ -72,7 +82,7 @@ type BlockEdge { cursor: String! """ - "The item at the end of the edge + The item at the end of the edge """ node: Block! } @@ -120,6 +130,11 @@ type CoinConnection { A list of edges. """ edges: [CoinEdge!]! + + """ + A list of nodes. + """ + nodes: [Coin!]! } """ @@ -132,7 +147,7 @@ type CoinEdge { cursor: String! """ - "The item at the end of the edge + The item at the end of the edge """ node: Coin! } @@ -168,11 +183,12 @@ type ConsensusParameters { maxGasPerTx: U64! maxScriptLength: U64! maxScriptDataLength: U64! - maxStaticContracts: U64! maxStorageSlots: U64! maxPredicateLength: U64! maxPredicateDataLength: U64! gasPriceFactor: U64! + gasPerByte: U64! + maxMessageDataLength: U64! } type Contract { @@ -197,6 +213,11 @@ type ContractBalanceConnection { A list of edges. """ edges: [ContractBalanceEdge!]! + + """ + A list of nodes. + """ + nodes: [ContractBalance!]! } """ @@ -209,7 +230,7 @@ type ContractBalanceEdge { cursor: String! """ - "The item at the end of the edge + The item at the end of the edge """ node: ContractBalance! } @@ -250,13 +271,14 @@ type FailureStatus { scalar HexString -union Input = InputCoin | InputContract +union Input = InputCoin | InputContract | InputMessage type InputCoin { utxoId: UtxoId! owner: Address! amount: U64! assetId: AssetId! + txPointer: TxPointer! witnessIndex: Int! maturity: U64! predicate: HexString! @@ -267,9 +289,73 @@ type InputContract { utxoId: UtxoId! balanceRoot: Bytes32! stateRoot: Bytes32! + txPointer: TxPointer! contract: Contract! } +type InputMessage { + messageId: MessageId! + sender: Address! + recipient: Address! + amount: U64! + nonce: U64! + owner: Address! + witnessIndex: Int! + data: HexString! + predicate: HexString! + predicateData: HexString! +} + +type Message { + amount: U64! + sender: Address! + recipient: Address! + owner: Address! + nonce: U64! + data: [Int!]! + daHeight: U64! + fuelBlockSpend: U64 +} + +type MessageConnection { + """ + Information to aid in pagination. + """ + pageInfo: PageInfo! + + """ + A list of edges. + """ + edges: [MessageEdge!]! + + """ + A list of nodes. + """ + nodes: [Message!]! +} + +""" +An edge in a connection. +""" +type MessageEdge { + """ + A cursor for use in pagination + """ + cursor: String! + + """ + The item at the end of the edge + """ + node: Message! +} + +scalar MessageId + +type MessageOutput { + recipient: Address! + amount: U64! +} + type Mutation { startSession: ID! endSession(id: ID!): Boolean! @@ -289,6 +375,7 @@ type Mutation { Submits transaction to the txpool """ submit(tx: HexString!): Transaction! + produceBlocks(blocksToProduce: U64!): U64! } type NodeInfo { @@ -296,7 +383,6 @@ type NodeInfo { predicates: Boolean! vmBacktrace: Boolean! minGasPrice: U64! - minBytePrice: U64! maxTx: U64! maxDepth: U64! nodeVersion: String! @@ -305,7 +391,7 @@ type NodeInfo { union Output = CoinOutput | ContractOutput - | WithdrawalOutput + | MessageOutput | ChangeOutput | VariableOutput | ContractCreated @@ -463,6 +549,16 @@ type Query { before: String ): ContractBalanceConnection! nodeInfo: NodeInfo! + messages( + """ + address of the owner + """ + owner: Address + first: Int + after: String + last: Int + before: String + ): MessageConnection! } type Receipt { @@ -490,6 +586,10 @@ type Receipt { result: U64 gasUsed: U64 data: HexString + messageId: MessageId + sender: Address + recipient: Address + nonce: Bytes32 } enum ReceiptType { @@ -503,6 +603,7 @@ enum ReceiptType { TRANSFER TRANSFER_OUT SCRIPT_RESULT + MESSAGE_OUT } enum ReturnType { @@ -514,6 +615,7 @@ enum ReturnType { type RunResult { state: RunState! breakpoint: OutputBreakpoint + jsonReceipts: [String!]! } enum RunState { @@ -558,7 +660,6 @@ type Transaction { inputContracts: [Contract!]! gasPrice: U64! gasLimit: U64! - bytePrice: U64! maturity: U64! isScript: Boolean! inputs: [Input!]! @@ -572,7 +673,6 @@ type Transaction { bytecodeWitnessIndex: Int bytecodeLength: U64 salt: Salt - staticContracts: [Contract!] storageSlots: [HexString!] """ @@ -591,6 +691,11 @@ type TransactionConnection { A list of edges. """ edges: [TransactionEdge!]! + + """ + A list of nodes. + """ + nodes: [Transaction!]! } """ @@ -603,7 +708,7 @@ type TransactionEdge { cursor: String! """ - "The item at the end of the edge + The item at the end of the edge """ node: Transaction! } @@ -612,6 +717,8 @@ scalar TransactionId union TransactionStatus = SubmittedStatus | SuccessStatus | FailureStatus +scalar TxPointer + scalar U64 scalar UtxoId @@ -621,9 +728,3 @@ type VariableOutput { amount: U64! assetId: AssetId! } - -type WithdrawalOutput { - to: Address! - amount: U64! - assetId: AssetId! -} diff --git a/packages/providers/src/operations.graphql b/packages/providers/src/operations.graphql index 2d8c8e82e30..75a6f54be62 100644 --- a/packages/providers/src/operations.graphql +++ b/packages/providers/src/operations.graphql @@ -69,6 +69,7 @@ fragment chainInfoFragment on ChainInfo { peerCount consensusParameters { gasPriceFactor + gasPerByte maxGasPerTx maxGasPerTx maxScriptLength @@ -89,7 +90,6 @@ query getInfo { nodeInfo { nodeVersion minGasPrice - minBytePrice } } diff --git a/packages/providers/src/provider.test.ts b/packages/providers/src/provider.test.ts index 9bd04992716..c0ce6cbcecc 100644 --- a/packages/providers/src/provider.test.ts +++ b/packages/providers/src/provider.test.ts @@ -12,7 +12,7 @@ describe('Provider', () => { const version = await provider.getVersion(); - expect(version).toEqual('0.9.6'); + expect(version).toEqual('0.10.1'); }); it('can call()', async () => { @@ -22,7 +22,6 @@ describe('Provider', () => { type: TransactionType.Script, gasPrice: 0n, gasLimit: 1000000n, - bytePrice: 0n, script: /* Opcode::ADDI(0x10, REG_ZERO, 0xCA) @@ -42,15 +41,15 @@ describe('Provider', () => { val1: BigInt(186), val2: BigInt(0), val3: BigInt(0), - pc: BigInt(0x2878), - is: BigInt(0x2870), + pc: BigInt(0x2870), + is: BigInt(0x2868), }, { type: ReceiptType.Return, id: ZeroBytes32, val: BigInt(1), - pc: BigInt(0x287c), - is: BigInt(0x2870), + pc: BigInt(0x2874), + is: BigInt(0x2868), }, { type: ReceiptType.ScriptResult, @@ -74,7 +73,6 @@ describe('Provider', () => { type: TransactionType.Script, gasPrice: 0n, gasLimit: 1000000n, - bytePrice: 0n, script: /* Opcode::ADDI(0x10, REG_ZERO, 0xCA) @@ -128,18 +126,18 @@ describe('Provider', () => { expect(endSessionSuccess).toEqual(true); }); - it('can get chain info including gasPriceFactor', async () => { + it('can get chain info including gasPriceFactor and gasPerByte', async () => { const provider = new Provider('http://127.0.0.1:4000/graphql'); const { consensusParameters } = await provider.getChain(); expect(consensusParameters.gasPriceFactor).toBeGreaterThan(0n); + expect(consensusParameters.gasPerByte).toBeGreaterThan(0n); }); - it('can get node info including minBytePrice and minGasPrice', async () => { + it('can get node info including minGasPrice', async () => { const provider = new Provider('http://127.0.0.1:4000/graphql'); - const { minBytePrice, minGasPrice } = await provider.getNodeInfo(); + const { minGasPrice } = await provider.getNodeInfo(); - expect(minBytePrice).toBeDefined(); expect(minGasPrice).toBeDefined(); }); }); diff --git a/packages/providers/src/provider.ts b/packages/providers/src/provider.ts index 72df4c2038b..397558e320e 100644 --- a/packages/providers/src/provider.ts +++ b/packages/providers/src/provider.ts @@ -5,6 +5,7 @@ import type { Network } from '@ethersproject/networks'; import { max, multiply } from '@fuel-ts/math'; import type { Transaction } from '@fuel-ts/transactions'; import { + GAS_PER_BYTE, GAS_PRICE_FACTOR, MAX_GAS_PER_TX, ReceiptType, @@ -61,6 +62,7 @@ export type ChainInfo = { peerCount: number; consensusParameters: { gasPriceFactor: bigint; + gasPerByte: bigint; maxGasPerTx: bigint; maxScriptLength: bigint; }; @@ -77,16 +79,13 @@ export type ChainInfo = { * Node information */ export type NodeInfo = { - minBytePrice: bigint; minGasPrice: bigint; nodeVersion: string; }; export type TransactionCost = { minGasPrice: bigint; - minBytePrice: bigint; gasPrice: bigint; - bytePrice: bigint; byteSize: bigint; gasUsed: bigint; fee: bigint; @@ -119,6 +118,7 @@ const processGqlChain = (chain: GqlChainInfoFragmentFragment): ChainInfo => ({ peerCount: chain.peerCount, consensusParameters: { gasPriceFactor: BigInt(chain.consensusParameters.gasPriceFactor), + gasPerByte: BigInt(chain.consensusParameters.gasPerByte), maxGasPerTx: BigInt(chain.consensusParameters.maxGasPerTx), maxScriptLength: BigInt(chain.consensusParameters.maxScriptLength), }, @@ -134,7 +134,6 @@ const processGqlChain = (chain: GqlChainInfoFragmentFragment): ChainInfo => ({ }); const processNodeInfo = (nodeInfo: GqlGetInfoQuery['nodeInfo']) => ({ - minBytePrice: BigInt(nodeInfo.minBytePrice), minGasPrice: BigInt(nodeInfo.minGasPrice), nodeVersion: nodeInfo.nodeVersion, }); @@ -227,10 +226,7 @@ export default class Provider { ): Promise { const transactionRequest = transactionRequestify(transactionRequestLike); const encodedTransaction = hexlify(transactionRequest.toTransactionBytes()); - const { gasUsed, minGasPrice, minBytePrice } = await this.getTransactionCost( - transactionRequest, - 0 - ); + const { gasUsed, minGasPrice } = await this.getTransactionCost(transactionRequest, 0); // Fail transaction before submit to avoid submit failure // Resulting in lost of funds on a OutOfGas situation. @@ -242,10 +238,6 @@ export default class Provider { throw new Error( `gasPrice(${transactionRequest.gasPrice}) is lower than the required ${minGasPrice}` ); - } else if (minBytePrice > transactionRequest.bytePrice) { - throw new Error( - `bytePrice(${transactionRequest.bytePrice}) is lower than the required ${minBytePrice}` - ); } const { @@ -290,16 +282,14 @@ export default class Provider { tolerance: number = 0.2 ): Promise { const transactionRequest = transactionRequestify(cloneDeep(transactionRequestLike)); - const { minBytePrice, minGasPrice } = await this.getNodeInfo(); + const { minGasPrice } = await this.getNodeInfo(); const gasPrice = max(transactionRequest.gasPrice, minGasPrice); - const bytePrice = max(transactionRequest.bytePrice, minBytePrice); const margin = 1 + tolerance; // Set gasLimit to the maximum of the chain - // and bytePrice and gasPrice to 0 for measure + // and gasPrice to 0 for measure // Transaction without arrive to OutOfGas transactionRequest.gasLimit = MAX_GAS_PER_TX; - transactionRequest.bytePrice = 0n; transactionRequest.gasPrice = 0n; // Execute dryRun not validated transaction to query gasUsed @@ -307,12 +297,11 @@ export default class Provider { const gasUsed = multiply(getGasUsedFromReceipts(receipts), margin); const byteSize = transactionRequest.chargeableByteSize(); const gasFee = calculatePriceWithFactor(gasUsed, gasPrice, GAS_PRICE_FACTOR); - const byteFee = calculatePriceWithFactor(byteSize, bytePrice, GAS_PRICE_FACTOR); + const gasPerBytePrice = multiply(GAS_PER_BYTE, gasPrice); + const byteFee = calculatePriceWithFactor(byteSize, gasPerBytePrice, GAS_PRICE_FACTOR); return { minGasPrice, - minBytePrice, - bytePrice, gasPrice, gasUsed, byteSize, diff --git a/packages/providers/src/transaction-request/transaction-request.ts b/packages/providers/src/transaction-request/transaction-request.ts index 06d429e2388..587a82c7dc2 100644 --- a/packages/providers/src/transaction-request/transaction-request.ts +++ b/packages/providers/src/transaction-request/transaction-request.ts @@ -5,8 +5,10 @@ import { NativeAssetId, ZeroBytes32 } from '@fuel-ts/constants'; import { addressify, contractIdify } from '@fuel-ts/interfaces'; import type { AddressLike, Address, ContractIdLike, AbstractScript } from '@fuel-ts/interfaces'; import type { BigNumberish } from '@fuel-ts/math'; +import { multiply } from '@fuel-ts/math'; import type { Transaction } from '@fuel-ts/transactions'; import { + GAS_PER_BYTE, TransactionType, TransactionCoder, InputType, @@ -57,8 +59,6 @@ interface BaseTransactionRequestLike { gasPrice?: BigNumberish; /** Gas limit for transaction */ gasLimit?: BigNumberish; - /** Price per transaction byte */ - bytePrice?: BigNumberish; /** Block until which tx cannot be included */ maturity?: BigNumberish; /** List of inputs */ @@ -92,7 +92,7 @@ export class NoWitnessByOwnerError extends Error { /** * The provider required at least 1 native coin - * even if the gasPrice and bytePrice are 0 + * even if the gasPrice = 0 */ export const MIN_TRANSACTION_AMOUNT = 1n; @@ -103,8 +103,6 @@ abstract class BaseTransactionRequest implements BaseTransactionRequestLike { gasPrice: bigint; /** Gas limit for transaction */ gasLimit: bigint; - /** Price per transaction byte */ - bytePrice: bigint; /** Block until which tx cannot be included */ maturity: bigint; /** List of inputs */ @@ -117,7 +115,6 @@ abstract class BaseTransactionRequest implements BaseTransactionRequestLike { constructor({ gasPrice, gasLimit, - bytePrice, maturity, inputs, outputs, @@ -125,7 +122,6 @@ abstract class BaseTransactionRequest implements BaseTransactionRequestLike { }: BaseTransactionRequestLike = {}) { this.gasPrice = BigInt(gasPrice ?? 0); this.gasLimit = BigInt(gasLimit ?? 0); - this.bytePrice = BigInt(bytePrice ?? 0); this.maturity = BigInt(maturity ?? 0); this.inputs = [...(inputs ?? [])]; this.outputs = [...(outputs ?? [])]; @@ -142,7 +138,6 @@ abstract class BaseTransactionRequest implements BaseTransactionRequestLike { return { gasPrice: this.gasPrice, gasLimit: this.gasLimit, - bytePrice: this.bytePrice, maturity: this.maturity, inputs, outputs, @@ -324,14 +319,14 @@ abstract class BaseTransactionRequest implements BaseTransactionRequestLike { * Return the minimum amount in native coins required to create * a transaction. * - * Note: this is required even if the gasPrice and bytePrice - * are set to zero. + * Note: this is required even gasPrice = 0 */ calculateFee(): CoinQuantity { const gasFee = calculatePriceWithFactor(this.gasLimit, this.gasPrice, GAS_PRICE_FACTOR); + const gasPerBytePrice = multiply(GAS_PER_BYTE, this.gasPrice); const byteFee = calculatePriceWithFactor( this.chargeableByteSize(), - this.bytePrice, + gasPerBytePrice, GAS_PRICE_FACTOR ); return { diff --git a/packages/testcases/src/sendTransaction.json b/packages/testcases/src/sendTransaction.json index b9caab7902d..d4c79ad48d3 100644 --- a/packages/testcases/src/sendTransaction.json +++ b/packages/testcases/src/sendTransaction.json @@ -3,7 +3,6 @@ "type": 0, "gasPrice": "0x00", "gasLimit": "0x0F4240", - "bytePrice": "0x00", "script": "0x24400000", "scriptData": "0x", "inputs": [ diff --git a/packages/testcases/src/signTransaction.json b/packages/testcases/src/signTransaction.json index bc14a4e7059..814dcabe980 100644 --- a/packages/testcases/src/signTransaction.json +++ b/packages/testcases/src/signTransaction.json @@ -3,7 +3,6 @@ "type": 0, "gasPrice": "0x00", "gasLimit": "0x0F4240", - "bytePrice": "0x00", "script": "0x24400000", "scriptData": "0x", "inputs": [ diff --git a/packages/transactions/src/coders/input.ts b/packages/transactions/src/coders/input.ts index 19aa6c83e0d..366fdd7248a 100644 --- a/packages/transactions/src/coders/input.ts +++ b/packages/transactions/src/coders/input.ts @@ -1,6 +1,6 @@ /* eslint-disable max-classes-per-file */ -import { concat } from '@ethersproject/bytes'; +import { concat, hexlify } from '@ethersproject/bytes'; import { Coder, B256Coder, NumberCoder } from '@fuel-ts/abi-coder'; import { ByteArrayCoder } from './byte-array'; @@ -44,10 +44,21 @@ export class InputCoinCoder extends Coder { encode(value: InputCoin): Uint8Array { const parts: Uint8Array[] = []; + // console.log(`value`, value); + // console.log( + // `new UtxoIdCoder().encode(value.utxoID)`, + // hexlify(new UtxoIdCoder().encode(value.utxoID)) + // ); + parts.push(new UtxoIdCoder().encode(value.utxoID)); parts.push(new B256Coder().encode(value.owner)); parts.push(new NumberCoder('u64').encode(value.amount)); parts.push(new B256Coder().encode(value.assetId)); + + // txPointer + parts.push(new NumberCoder('u16').encode(0)); + // txPointer + parts.push(new NumberCoder('u8').encode(value.witnessIndex)); parts.push(new NumberCoder('u64').encode(value.maturity)); parts.push(new NumberCoder('u16').encode(value.predicateLength)); diff --git a/packages/transactions/src/coders/transaction.test.ts b/packages/transactions/src/coders/transaction.test.ts index 97ff25262ff..024e709d727 100644 --- a/packages/transactions/src/coders/transaction.test.ts +++ b/packages/transactions/src/coders/transaction.test.ts @@ -11,7 +11,6 @@ describe('TransactionCoder', () => { type: TransactionType.Script, gasPrice: 0n, gasLimit: 0n, - bytePrice: 0n, maturity: 0n, scriptLength: 0, scriptDataLength: 0, @@ -43,7 +42,6 @@ describe('TransactionCoder', () => { type: TransactionType.Create, gasPrice: 0n, gasLimit: 0n, - bytePrice: 0n, maturity: 0n, bytecodeLength: 0, bytecodeWitnessIndex: 0, diff --git a/packages/transactions/src/coders/transaction.ts b/packages/transactions/src/coders/transaction.ts index 55d4af4b25c..ec9779eaae0 100644 --- a/packages/transactions/src/coders/transaction.ts +++ b/packages/transactions/src/coders/transaction.ts @@ -1,6 +1,6 @@ /* eslint-disable max-classes-per-file */ -import { concat } from '@ethersproject/bytes'; +import { concat, hexlify } from '@ethersproject/bytes'; import { Coder, ArrayCoder, B256Coder, NumberCoder } from '@fuel-ts/abi-coder'; import { ByteArrayCoder } from './byte-array'; @@ -24,8 +24,6 @@ export type TransactionScript = { gasPrice: bigint; /** Gas limit for transaction (u64) */ gasLimit: bigint; - /** Price per transaction byte (u64) */ - bytePrice: bigint; /** Block until which tx cannot be included (u64) */ maturity: bigint; /** Script length, in instructions (u16) */ @@ -60,9 +58,15 @@ export class TransactionScriptCoder extends Coder { const result = await sender.transfer(receiver.address, 1, NativeAssetId, { gasLimit: 1, gasPrice: 1, - bytePrice: 1, }); await result.wait(); }).rejects.toThrowError('gasLimit(1) is lower than the required (11)'); diff --git a/packages/wallet/src/wallet.ts b/packages/wallet/src/wallet.ts index 4db9a4d3b37..5248f5e9bb2 100644 --- a/packages/wallet/src/wallet.ts +++ b/packages/wallet/src/wallet.ts @@ -194,7 +194,7 @@ export default class Wallet extends AbstractWallet { /** Asset ID of coins */ assetId: BytesLike = NativeAssetId, /** Tx Params */ - txParams: Pick = {} + txParams: Pick = {} ): Promise { const params = { gasLimit: MAX_GAS_PER_TX, ...txParams }; const request = new ScriptTransactionRequest(params); diff --git a/services/fuel-core/Dockerfile b/services/fuel-core/Dockerfile index 51e1167dd79..9aae1ac525c 100644 --- a/services/fuel-core/Dockerfile +++ b/services/fuel-core/Dockerfile @@ -1,16 +1,14 @@ -FROM ghcr.io/fuellabs/fuel-core:v0.9.6 +FROM ghcr.io/fuellabs/fuel-core:v0.10.1 ARG IP=0.0.0.0 ARG PORT=4000 ARG MIN_GAS_PRICE=0 -ARG MIN_BYTE_PRICE=0 ARG DB_PATH=./mnt/db/ ENV IP="${IP}" ENV PORT="${PORT}" ENV DB_PATH="${DB_PATH}" ENV MIN_GAS_PRICE="${MIN_GAS_PRICE}" -ENV MIN_BYTE_PRICE="${MIN_BYTE_PRICE}" WORKDIR /root/ @@ -19,13 +17,12 @@ COPY chainConfig.json . # https://stackoverflow.com/a/44671685 # https://stackoverflow.com/a/40454758 # hadolint ignore=DL3025 -CMD exec ./fuel-core \ +CMD exec ./fuel-core run \ --ip ${IP} \ --port ${PORT} \ --db-path ${DB_PATH} \ --utxo-validation \ --min-gas-price ${MIN_GAS_PRICE} \ - --min-byte-price ${MIN_BYTE_PRICE} \ --vm-backtrace \ --predicates \ --chain ./chainConfig.json From b1984b423838930ea8c606727e51bc564d23ab5b Mon Sep 17 00:00:00 2001 From: Luiz Felipe Bolsoni Gomes Date: Tue, 16 Aug 2022 18:55:52 -0300 Subject: [PATCH 02/17] chore: commit to debug --- .../src/__test__/contract-factory.test.ts | 23 +++-- packages/script/src/script.ts | 1 + packages/transactions/src/coders/input.ts | 23 +++++ services/fuel-core/chainConfig.json | 96 +++++++++---------- 4 files changed, 87 insertions(+), 56 deletions(-) diff --git a/packages/contract/src/__test__/contract-factory.test.ts b/packages/contract/src/__test__/contract-factory.test.ts index 777a4ecbec1..9b31590305e 100644 --- a/packages/contract/src/__test__/contract-factory.test.ts +++ b/packages/contract/src/__test__/contract-factory.test.ts @@ -1,3 +1,4 @@ +import { hexlify } from '@ethersproject/bytes'; import { Interface } from '@fuel-ts/abi-coder'; import { NativeAssetId } from '@fuel-ts/constants'; import { Provider } from '@fuel-ts/providers'; @@ -128,17 +129,23 @@ describe('Contract Factory', () => { const factory = await createContractFactory(); const b256 = '0x626f0c36909faecc316056fca8be684ab0cd06afc63247dc008bdf9e433f927a'; - expect(true); + // expect(true); - // const contract = await factory.deployContract({ - // storageSlots: [ - // ...storageSlots, // initializing from storage_slots.json - // { key: '0000000000000000000000000000000000000000000000000000000000000001', value: b256 }, // Initializing manual value - // ], - // }); + const contract = await factory.deployContract({ + storageSlots: [ + ...storageSlots, // initializing from storage_slots.json + { key: '0000000000000000000000000000000000000000000000000000000000000001', value: b256 }, // Initializing manual value + ], + }); + const fn = await contract.functions.return_var1(); + console.log( + `transactionRequest.toTransactionBytes()`, + hexlify(fn.transactionRequest.toTransactionBytes()) + ); // const { value: var1 } = await contract.functions.return_var1().call(); - // expect(var1).toEqual(10n); + const { value: var1 } = await fn.call(); + expect(var1).toEqual(10n); // const { value: var2 } = await contract.functions.return_var2().call(); // expect(var2).toEqual(20); diff --git a/packages/script/src/script.ts b/packages/script/src/script.ts index 7df8d7447a4..27c18ffbf9e 100644 --- a/packages/script/src/script.ts +++ b/packages/script/src/script.ts @@ -33,6 +33,7 @@ export type ScriptResult = { }; function callResultToScriptResult(callResult: CallResult): ScriptResult { + console.log(`callResult`, callResult); const receipts = [...callResult.receipts]; // Every script call ends with two specific receipts diff --git a/packages/transactions/src/coders/input.ts b/packages/transactions/src/coders/input.ts index 366fdd7248a..174cf1bc25c 100644 --- a/packages/transactions/src/coders/input.ts +++ b/packages/transactions/src/coders/input.ts @@ -57,6 +57,7 @@ export class InputCoinCoder extends Coder { // txPointer parts.push(new NumberCoder('u16').encode(0)); + parts.push(new NumberCoder('u16').encode(0)); // txPointer parts.push(new NumberCoder('u8').encode(value.witnessIndex)); @@ -81,6 +82,14 @@ export class InputCoinCoder extends Coder { const amount = decoded; [decoded, o] = new B256Coder().decode(data, o); const assetId = decoded; + + // txPointer + [decoded, o] = new NumberCoder('u16').decode(data, o); + const txPointer = Number(decoded); + [decoded, o] = new NumberCoder('u16').decode(data, o); + const txPointer2 = Number(decoded); + // txPointer + [decoded, o] = new NumberCoder('u8').decode(data, o); const witnessIndex = Number(decoded); [decoded, o] = new NumberCoder('u64').decode(data, o); @@ -140,6 +149,12 @@ export class InputContractCoder extends Coder { parts.push(new UtxoIdCoder().encode(value.utxoID)); parts.push(new B256Coder().encode(value.balanceRoot)); parts.push(new B256Coder().encode(value.stateRoot)); + + // txPointer + parts.push(new NumberCoder('u16').encode(0)); + parts.push(new NumberCoder('u16').encode(0)); + // txPointer + parts.push(new B256Coder().encode(value.contractID)); return concat(parts); @@ -155,6 +170,14 @@ export class InputContractCoder extends Coder { const balanceRoot = decoded; [decoded, o] = new B256Coder().decode(data, o); const stateRoot = decoded; + + // txPointer + [decoded, o] = new NumberCoder('u16').decode(data, o); + const txPointer = Number(decoded); + [decoded, o] = new NumberCoder('u16').decode(data, o); + const txPointer2 = Number(decoded); + // txPointer + [decoded, o] = new B256Coder().decode(data, o); const contractID = decoded; diff --git a/services/fuel-core/chainConfig.json b/services/fuel-core/chainConfig.json index 37d18ee0b62..5749dc44394 100644 --- a/services/fuel-core/chainConfig.json +++ b/services/fuel-core/chainConfig.json @@ -8,242 +8,242 @@ "coins": [ { "owner": "0x09c0b2d1a486c439a87bcba6b46a7a1a23f3897cc83a94521a96da5c23bc58db", - "amount": "0xFFFFFFFFFFFFFFFF", + "amount": "0x0000FFFFFFFFFFFF", "asset_id": "0x0000000000000000000000000000000000000000000000000000000000000000" }, { "owner": "0x09c0b2d1a486c439a87bcba6b46a7a1a23f3897cc83a94521a96da5c23bc58db", - "amount": "0xFFFFFFFFFFFFFFFF", + "amount": "0x0000FFFFFFFFFFFF", "asset_id": "0x0101010101010101010101010101010101010101010101010101010101010101" }, { "owner": "0x09c0b2d1a486c439a87bcba6b46a7a1a23f3897cc83a94521a96da5c23bc58db", - "amount": "0xFFFFFFFFFFFFFFFF", + "amount": "0x0000FFFFFFFFFFFF", "asset_id": "0x0202020202020202020202020202020202020202020202020202020202020202" }, { "owner": "0x5d99ee966b42cd8fc7bdd1364b389153a9e78b42b7d4a691470674e817888d4e", - "amount": "0xFFFFFFFFFFFFFFFF", + "amount": "0x0000FFFFFFFFFFFF", "asset_id": "0x0000000000000000000000000000000000000000000000000000000000000000" }, { "owner": "0x5d99ee966b42cd8fc7bdd1364b389153a9e78b42b7d4a691470674e817888d4e", - "amount": "0xFFFFFFFFFFFFFFFF", + "amount": "0x0000FFFFFFFFFFFF", "asset_id": "0x0101010101010101010101010101010101010101010101010101010101010101" }, { "owner": "0x5d99ee966b42cd8fc7bdd1364b389153a9e78b42b7d4a691470674e817888d4e", - "amount": "0xFFFFFFFFFFFFFFFF", + "amount": "0x0000FFFFFFFFFFFF", "asset_id": "0x0202020202020202020202020202020202020202020202020202020202020202" }, { "owner": "0xbdaad6a89e073e177895b3e5a9ccd15806749eda134a6438dae32fc5b6601f3f", - "amount": "0xFFFFFFFFFFFFFFFF", + "amount": "0x0000FFFFFFFFFFFF", "asset_id": "0x0000000000000000000000000000000000000000000000000000000000000000" }, { "owner": "0xbdaad6a89e073e177895b3e5a9ccd15806749eda134a6438dae32fc5b6601f3f", - "amount": "0xFFFFFFFFFFFFFFFF", + "amount": "0x0000FFFFFFFFFFFF", "asset_id": "0x0101010101010101010101010101010101010101010101010101010101010101" }, { "owner": "0xbdaad6a89e073e177895b3e5a9ccd15806749eda134a6438dae32fc5b6601f3f", - "amount": "0xFFFFFFFFFFFFFFFF", + "amount": "0x0000FFFFFFFFFFFF", "asset_id": "0x0202020202020202020202020202020202020202020202020202020202020202" }, { "owner": "0x95a7aa6cc32743f8706c40ef49a7423b47da763bb4bbc055b1f07254dc729036", - "amount": "0xFFFFFFFFFFFFFFFF", + "amount": "0x0000FFFFFFFFFFFF", "asset_id": "0x0000000000000000000000000000000000000000000000000000000000000000" }, { "owner": "0x95a7aa6cc32743f8706c40ef49a7423b47da763bb4bbc055b1f07254dc729036", - "amount": "0xFFFFFFFFFFFFFFFF", + "amount": "0x0000FFFFFFFFFFFF", "asset_id": "0x0101010101010101010101010101010101010101010101010101010101010101" }, { "owner": "0x95a7aa6cc32743f8706c40ef49a7423b47da763bb4bbc055b1f07254dc729036", - "amount": "0xFFFFFFFFFFFFFFFF", + "amount": "0x0000FFFFFFFFFFFF", "asset_id": "0x0202020202020202020202020202020202020202020202020202020202020202" }, { "owner": "0xcee104acd38b940c8f1c62c6d7ea00a0ad2241d6dee0509a4bf27297508870d3", - "amount": "0xFFFFFFFFFFFFFFFF", + "amount": "0x0000FFFFFFFFFFFF", "asset_id": "0x0000000000000000000000000000000000000000000000000000000000000000" }, { "owner": "0xcee104acd38b940c8f1c62c6d7ea00a0ad2241d6dee0509a4bf27297508870d3", - "amount": "0xFFFFFFFFFFFFFFFF", + "amount": "0x0000FFFFFFFFFFFF", "asset_id": "0x0101010101010101010101010101010101010101010101010101010101010101" }, { "owner": "0xcee104acd38b940c8f1c62c6d7ea00a0ad2241d6dee0509a4bf27297508870d3", - "amount": "0xFFFFFFFFFFFFFFFF", + "amount": "0x0000FFFFFFFFFFFF", "asset_id": "0x0202020202020202020202020202020202020202020202020202020202020202" }, { "owner": "0x7e3626e306588eba79cafab73f0709e55ab8f4bdfe8c8b75034a430fc56ece89", - "amount": "0xFFFFFFFFFFFFFFFF", + "amount": "0x0000FFFFFFFFFFFF", "asset_id": "0x0000000000000000000000000000000000000000000000000000000000000000" }, { "owner": "0x7e3626e306588eba79cafab73f0709e55ab8f4bdfe8c8b75034a430fc56ece89", - "amount": "0xFFFFFFFFFFFFFFFF", + "amount": "0x0000FFFFFFFFFFFF", "asset_id": "0x0101010101010101010101010101010101010101010101010101010101010101" }, { "owner": "0x7e3626e306588eba79cafab73f0709e55ab8f4bdfe8c8b75034a430fc56ece89", - "amount": "0xFFFFFFFFFFFFFFFF", + "amount": "0x0000FFFFFFFFFFFF", "asset_id": "0x0202020202020202020202020202020202020202020202020202020202020202" }, { "owner": "0x1c31df52b6df56407dd95f83082e8beb9cfc9532ac111d5bd8491651d95ba775", - "amount": "0xFFFFFFFFFFFFFFFF", + "amount": "0x0000FFFFFFFFFFFF", "asset_id": "0x0000000000000000000000000000000000000000000000000000000000000000" }, { "owner": "0x1c31df52b6df56407dd95f83082e8beb9cfc9532ac111d5bd8491651d95ba775", - "amount": "0xFFFFFFFFFFFFFFFF", + "amount": "0x0000FFFFFFFFFFFF", "asset_id": "0x0101010101010101010101010101010101010101010101010101010101010101" }, { "owner": "0x1c31df52b6df56407dd95f83082e8beb9cfc9532ac111d5bd8491651d95ba775", - "amount": "0xFFFFFFFFFFFFFFFF", + "amount": "0x0000FFFFFFFFFFFF", "asset_id": "0x0202020202020202020202020202020202020202020202020202020202020202" }, { "owner": "0x09dd7a49174d6fcc9f4c6f7942c18060a935ddd03ee69b594189b8c3581276ea", - "amount": "0xFFFFFFFFFFFFFFFF", + "amount": "0x0000FFFFFFFFFFFF", "asset_id": "0x0000000000000000000000000000000000000000000000000000000000000000" }, { "owner": "0x09dd7a49174d6fcc9f4c6f7942c18060a935ddd03ee69b594189b8c3581276ea", - "amount": "0xFFFFFFFFFFFFFFFF", + "amount": "0x0000FFFFFFFFFFFF", "asset_id": "0x0101010101010101010101010101010101010101010101010101010101010101" }, { "owner": "0x09dd7a49174d6fcc9f4c6f7942c18060a935ddd03ee69b594189b8c3581276ea", - "amount": "0xFFFFFFFFFFFFFFFF", + "amount": "0x0000FFFFFFFFFFFF", "asset_id": "0x0202020202020202020202020202020202020202020202020202020202020202" }, { "owner": "0x86604282dc604481b809845be49667607c470644f6822fc01eb0d22f167e08cf", - "amount": "0xFFFFFFFFFFFFFFFF", + "amount": "0x0000FFFFFFFFFFFF", "asset_id": "0x0000000000000000000000000000000000000000000000000000000000000000" }, { "owner": "0x86604282dc604481b809845be49667607c470644f6822fc01eb0d22f167e08cf", - "amount": "0xFFFFFFFFFFFFFFFF", + "amount": "0x0000FFFFFFFFFFFF", "asset_id": "0x0101010101010101010101010101010101010101010101010101010101010101" }, { "owner": "0x86604282dc604481b809845be49667607c470644f6822fc01eb0d22f167e08cf", - "amount": "0xFFFFFFFFFFFFFFFF", + "amount": "0x0000FFFFFFFFFFFF", "asset_id": "0x0202020202020202020202020202020202020202020202020202020202020202" }, { "owner": "0xbca334a06d19db5041c78fe2f465b07be5bec828f38b7796b2877e7d1542c950", - "amount": "0xFFFFFFFFFFFFFFFF", + "amount": "0x0000FFFFFFFFFFFF", "asset_id": "0x0000000000000000000000000000000000000000000000000000000000000000" }, { "owner": "0xbca334a06d19db5041c78fe2f465b07be5bec828f38b7796b2877e7d1542c950", - "amount": "0xFFFFFFFFFFFFFFFF", + "amount": "0x0000FFFFFFFFFFFF", "asset_id": "0x0101010101010101010101010101010101010101010101010101010101010101" }, { "owner": "0xbca334a06d19db5041c78fe2f465b07be5bec828f38b7796b2877e7d1542c950", - "amount": "0xFFFFFFFFFFFFFFFF", + "amount": "0x0000FFFFFFFFFFFF", "asset_id": "0x0202020202020202020202020202020202020202020202020202020202020202" }, { "owner": "0xbd9a1dc8d3ec3521c43f6c2c01611b4d0204c7610204ff0178488c8738a30bd2", - "amount": "0xFFFFFFFFFFFFFFFF", + "amount": "0x0000FFFFFFFFFFFF", "asset_id": "0x0000000000000000000000000000000000000000000000000000000000000000" }, { "owner": "0xbd9a1dc8d3ec3521c43f6c2c01611b4d0204c7610204ff0178488c8738a30bd2", - "amount": "0xFFFFFFFFFFFFFFFF", + "amount": "0x0000FFFFFFFFFFFF", "asset_id": "0x0101010101010101010101010101010101010101010101010101010101010101" }, { "owner": "0xbd9a1dc8d3ec3521c43f6c2c01611b4d0204c7610204ff0178488c8738a30bd2", - "amount": "0xFFFFFFFFFFFFFFFF", + "amount": "0x0000FFFFFFFFFFFF", "asset_id": "0x0202020202020202020202020202020202020202020202020202020202020202" }, { "owner": "0xb32197cf75efe05bf453c26178139f09b391582065549c1422bc92555ecffb64", - "amount": "0xFFFFFFFFFFFFFFFF", + "amount": "0x0000FFFFFFFFFFFF", "asset_id": "0x0000000000000000000000000000000000000000000000000000000000000000" }, { "owner": "0xb32197cf75efe05bf453c26178139f09b391582065549c1422bc92555ecffb64", - "amount": "0xFFFFFFFFFFFFFFFF", + "amount": "0x0000FFFFFFFFFFFF", "asset_id": "0x0101010101010101010101010101010101010101010101010101010101010101" }, { "owner": "0xb32197cf75efe05bf453c26178139f09b391582065549c1422bc92555ecffb64", - "amount": "0xFFFFFFFFFFFFFFFF", + "amount": "0x0000FFFFFFFFFFFF", "asset_id": "0x0202020202020202020202020202020202020202020202020202020202020202" }, { "owner": "0x3b24509ed4ab3c7959f5c9391c1445c59290cdb5f13d6f780922f376b7029f30", - "amount": "0xFFFFFFFFFFFFFFFF", + "amount": "0x0000FFFFFFFFFFFF", "asset_id": "0x0000000000000000000000000000000000000000000000000000000000000000" }, { "owner": "0x3b24509ed4ab3c7959f5c9391c1445c59290cdb5f13d6f780922f376b7029f30", - "amount": "0xFFFFFFFFFFFFFFFF", + "amount": "0x0000FFFFFFFFFFFF", "asset_id": "0x0101010101010101010101010101010101010101010101010101010101010101" }, { "owner": "0x3b24509ed4ab3c7959f5c9391c1445c59290cdb5f13d6f780922f376b7029f30", - "amount": "0xFFFFFFFFFFFFFFFF", + "amount": "0x0000FFFFFFFFFFFF", "asset_id": "0x0202020202020202020202020202020202020202020202020202020202020202" }, { "owner": "0x77c6f40b7da70d885f68efaad7c661327482a63ea10dcb4271de819438254ae1", - "amount": "0xFFFFFFFFFFFFFFFF", + "amount": "0x0000FFFFFFFFFFFF", "asset_id": "0x0000000000000000000000000000000000000000000000000000000000000000" }, { "owner": "0x77c6f40b7da70d885f68efaad7c661327482a63ea10dcb4271de819438254ae1", - "amount": "0xFFFFFFFFFFFFFFFF", + "amount": "0x0000FFFFFFFFFFFF", "asset_id": "0x0101010101010101010101010101010101010101010101010101010101010101" }, { "owner": "0x77c6f40b7da70d885f68efaad7c661327482a63ea10dcb4271de819438254ae1", - "amount": "0xFFFFFFFFFFFFFFFF", + "amount": "0x0000FFFFFFFFFFFF", "asset_id": "0x0202020202020202020202020202020202020202020202020202020202020202" }, { "owner": "0x6a2c4691c547c43924650dbd30620b184b5fe3fb6dbe5c4446110b08f6f405bf", - "amount": "0xFFFFFFFFFFFFFFFF", + "amount": "0x0000FFFFFFFFFFFF", "asset_id": "0x0000000000000000000000000000000000000000000000000000000000000000" }, { "owner": "0x6a2c4691c547c43924650dbd30620b184b5fe3fb6dbe5c4446110b08f6f405bf", - "amount": "0xFFFFFFFFFFFFFFFF", + "amount": "0x0000FFFFFFFFFFFF", "asset_id": "0x0101010101010101010101010101010101010101010101010101010101010101" }, { "owner": "0x6a2c4691c547c43924650dbd30620b184b5fe3fb6dbe5c4446110b08f6f405bf", - "amount": "0xFFFFFFFFFFFFFFFF", + "amount": "0x0000FFFFFFFFFFFF", "asset_id": "0x0202020202020202020202020202020202020202020202020202020202020202" }, { "owner": "0x49075a7538e2c88ebe1926ce4d898198a2a4e790d14512943a9864bc536b3c82", - "amount": "0xFFFFFFFFFFFFFFFF", + "amount": "0x0000FFFFFFFFFFFF", "asset_id": "0x0000000000000000000000000000000000000000000000000000000000000000" }, { "owner": "0x49075a7538e2c88ebe1926ce4d898198a2a4e790d14512943a9864bc536b3c82", - "amount": "0xFFFFFFFFFFFFFFFF", + "amount": "0x0000FFFFFFFFFFFF", "asset_id": "0x0101010101010101010101010101010101010101010101010101010101010101" }, { "owner": "0x49075a7538e2c88ebe1926ce4d898198a2a4e790d14512943a9864bc536b3c82", - "amount": "0xFFFFFFFFFFFFFFFF", + "amount": "0x0000FFFFFFFFFFFF", "asset_id": "0x0202020202020202020202020202020202020202020202020202020202020202" } ] From 6ab3db1b702113e61a43df85d320c20c71610dc5 Mon Sep 17 00:00:00 2001 From: Luiz Felipe Bolsoni Gomes Date: Fri, 19 Aug 2022 13:05:28 -0300 Subject: [PATCH 03/17] fix: change maturity to u32 + add txPointer --- .../src/__test__/contract-factory.test.ts | 40 ++++------ packages/providers/src/coin.ts | 2 +- packages/providers/src/provider.ts | 4 +- .../src/transaction-request/input.ts | 31 +++++++- .../transaction-request.ts | 8 +- packages/script/src/script.ts | 1 - packages/transactions/src/coders/input.ts | 74 +++++++++---------- .../src/coders/transaction.test.ts | 4 +- .../transactions/src/coders/transaction.ts | 31 ++------ .../src/coders/tx-pointer.test.ts | 36 +++++++++ .../transactions/src/coders/tx-pointer.ts | 21 ++++++ packages/transactions/src/index.ts | 1 + 12 files changed, 154 insertions(+), 99 deletions(-) create mode 100644 packages/transactions/src/coders/tx-pointer.test.ts create mode 100644 packages/transactions/src/coders/tx-pointer.ts diff --git a/packages/contract/src/__test__/contract-factory.test.ts b/packages/contract/src/__test__/contract-factory.test.ts index 9b31590305e..cb7db622c87 100644 --- a/packages/contract/src/__test__/contract-factory.test.ts +++ b/packages/contract/src/__test__/contract-factory.test.ts @@ -1,4 +1,4 @@ -import { hexlify } from '@ethersproject/bytes'; +import { arrayify, hexlify } from '@ethersproject/bytes'; import { Interface } from '@fuel-ts/abi-coder'; import { NativeAssetId } from '@fuel-ts/constants'; import { Provider } from '@fuel-ts/providers'; @@ -125,12 +125,10 @@ describe('Contract Factory', () => { expect(vB256).toEqual(b256); }); - it.only('Creates a contract with initial storage. Both dynamic key and fixed vars', async () => { + it('Creates a contract with initial storage. Both dynamic key and fixed vars', async () => { const factory = await createContractFactory(); const b256 = '0x626f0c36909faecc316056fca8be684ab0cd06afc63247dc008bdf9e433f927a'; - // expect(true); - const contract = await factory.deployContract({ storageSlots: [ ...storageSlots, // initializing from storage_slots.json @@ -138,31 +136,25 @@ describe('Contract Factory', () => { ], }); - const fn = await contract.functions.return_var1(); - console.log( - `transactionRequest.toTransactionBytes()`, - hexlify(fn.transactionRequest.toTransactionBytes()) - ); - // const { value: var1 } = await contract.functions.return_var1().call(); - const { value: var1 } = await fn.call(); + const { value: var1 } = await contract.functions.return_var1().call(); expect(var1).toEqual(10n); - // const { value: var2 } = await contract.functions.return_var2().call(); - // expect(var2).toEqual(20); + const { value: var2 } = await contract.functions.return_var2().call(); + expect(var2).toEqual(20); - // const { value: var3 } = await contract.functions.return_var3().call(); - // expect(var3).toEqual(30); + const { value: var3 } = await contract.functions.return_var3().call(); + expect(var3).toEqual(30); - // const { value: var4 } = await contract.functions.return_var4().call(); - // expect(var4).toEqual(true); + const { value: var4 } = await contract.functions.return_var4().call(); + expect(var4).toEqual(true); - // const { value: var5 } = await contract.functions.return_var5().call(); - // expect(var5).toEqual({ - // v1: true, - // v2: 50n, - // }); + const { value: var5 } = await contract.functions.return_var5().call(); + expect(var5).toEqual({ + v1: true, + v2: 50n, + }); - // const { value: vB256 } = await contract.functions.return_b256().get(); - // expect(vB256).toEqual(b256); + const { value: vB256 } = await contract.functions.return_b256().get(); + expect(vB256).toEqual(b256); }); }); diff --git a/packages/providers/src/coin.ts b/packages/providers/src/coin.ts index 7943ba692ff..d87a574448d 100644 --- a/packages/providers/src/coin.ts +++ b/packages/providers/src/coin.ts @@ -9,7 +9,7 @@ export type Coin = { amount: bigint; owner: string; status: CoinStatus; - maturity: bigint; + maturity: number; blockCreated: bigint; }; diff --git a/packages/providers/src/provider.ts b/packages/providers/src/provider.ts index 397558e320e..d3c57467251 100644 --- a/packages/providers/src/provider.ts +++ b/packages/providers/src/provider.ts @@ -334,7 +334,7 @@ export default class Provider { amount: BigInt(coin.amount), owner: coin.owner, status: coin.status, - maturity: BigInt(coin.maturity), + maturity: Number(coin.maturity), blockCreated: BigInt(coin.blockCreated), })); } @@ -367,7 +367,7 @@ export default class Provider { assetId: coin.assetId, amount: BigInt(coin.amount), owner: coin.owner, - maturity: BigInt(coin.maturity), + maturity: Number(coin.maturity), blockCreated: BigInt(coin.blockCreated), })); } diff --git a/packages/providers/src/transaction-request/input.ts b/packages/providers/src/transaction-request/input.ts index a38360890e3..486e27fd60c 100644 --- a/packages/providers/src/transaction-request/input.ts +++ b/packages/providers/src/transaction-request/input.ts @@ -2,30 +2,46 @@ import type { BytesLike } from '@ethersproject/bytes'; import { arrayify, hexlify } from '@ethersproject/bytes'; import { ZeroBytes32 } from '@fuel-ts/constants'; import type { BigNumberish } from '@fuel-ts/math'; -import type { Input } from '@fuel-ts/transactions'; +import { toNumber } from '@fuel-ts/math'; +import type { Input, TxPointer } from '@fuel-ts/transactions'; import { InputType } from '@fuel-ts/transactions'; export type CoinTransactionRequestInput = { type: InputType.Coin; + /** UTXO ID */ id: BytesLike; + /** Owning address or script hash */ owner: BytesLike; + /** Amount of coins */ amount: BigNumberish; + /** Asset ID of the coins */ assetId: BytesLike; + + /** Points to the TX whose output is being spent. (TxPointer) */ + txPointer: BytesLike; + /** Index of witness that authorizes spending the coin */ witnessIndex: number; + /** UTXO being spent must have been created at least this many blocks ago */ - maturity?: BigNumberish; + maturity?: number; + /** Predicate bytecode */ predicate?: BytesLike; + /** Predicate input data (parameters) */ predicateData?: BytesLike; }; export type ContractTransactionRequestInput = { type: InputType.Contract; + + /** Points to the TX whose output is being spent. (TxPointer) */ + txPointer: BytesLike; + /** Contract ID */ contractId: BytesLike; }; @@ -45,8 +61,12 @@ export const inputify = (value: TransactionRequestInput): Input => { owner: hexlify(value.owner), amount: BigInt(value.amount), assetId: hexlify(value.assetId), + txPointer: { + blockHeight: toNumber(arrayify(value.txPointer).slice(0, 8)), + txIndex: toNumber(arrayify(value.txPointer).slice(8, 16)), + }, witnessIndex: value.witnessIndex, - maturity: BigInt(value.maturity ?? 0), + maturity: value.maturity ?? 0, predicateLength: predicate.length, predicateDataLength: predicateData.length, predicate: hexlify(predicate), @@ -62,6 +82,11 @@ export const inputify = (value: TransactionRequestInput): Input => { }, balanceRoot: ZeroBytes32, stateRoot: ZeroBytes32, + + txPointer: { + blockHeight: arrayify(value.txPointer)[16], + txIndex: arrayify(value.txPointer)[32], + }, contractID: hexlify(value.contractId), }; } diff --git a/packages/providers/src/transaction-request/transaction-request.ts b/packages/providers/src/transaction-request/transaction-request.ts index 587a82c7dc2..01fa0cc18b1 100644 --- a/packages/providers/src/transaction-request/transaction-request.ts +++ b/packages/providers/src/transaction-request/transaction-request.ts @@ -60,7 +60,7 @@ interface BaseTransactionRequestLike { /** Gas limit for transaction */ gasLimit?: BigNumberish; /** Block until which tx cannot be included */ - maturity?: BigNumberish; + maturity?: number; /** List of inputs */ inputs?: TransactionRequestInput[]; /** List of outputs */ @@ -104,7 +104,7 @@ abstract class BaseTransactionRequest implements BaseTransactionRequestLike { /** Gas limit for transaction */ gasLimit: bigint; /** Block until which tx cannot be included */ - maturity: bigint; + maturity: number; /** List of inputs */ inputs: TransactionRequestInput[] = []; /** List of outputs */ @@ -122,7 +122,7 @@ abstract class BaseTransactionRequest implements BaseTransactionRequestLike { }: BaseTransactionRequestLike = {}) { this.gasPrice = BigInt(gasPrice ?? 0); this.gasLimit = BigInt(gasLimit ?? 0); - this.maturity = BigInt(maturity ?? 0); + this.maturity = maturity ?? 0; this.inputs = [...(inputs ?? [])]; this.outputs = [...(outputs ?? [])]; this.witnesses = [...(witnesses ?? [])]; @@ -248,6 +248,7 @@ abstract class BaseTransactionRequest implements BaseTransactionRequestLike { type: InputType.Coin, ...coin, witnessIndex, + txPointer: '0x00000000000000000000000000000000', }); // Find the ChangeOutput for the AssetId of the Coin @@ -424,6 +425,7 @@ export class ScriptTransactionRequest extends BaseTransactionRequest { const inputIndex = super.pushInput({ type: InputType.Contract, + txPointer: '0x00000000000000000000000000000000', contractId, }); diff --git a/packages/script/src/script.ts b/packages/script/src/script.ts index 27c18ffbf9e..7df8d7447a4 100644 --- a/packages/script/src/script.ts +++ b/packages/script/src/script.ts @@ -33,7 +33,6 @@ export type ScriptResult = { }; function callResultToScriptResult(callResult: CallResult): ScriptResult { - console.log(`callResult`, callResult); const receipts = [...callResult.receipts]; // Every script call ends with two specific receipts diff --git a/packages/transactions/src/coders/input.ts b/packages/transactions/src/coders/input.ts index 174cf1bc25c..cd001f8779f 100644 --- a/packages/transactions/src/coders/input.ts +++ b/packages/transactions/src/coders/input.ts @@ -1,9 +1,11 @@ /* eslint-disable max-classes-per-file */ -import { concat, hexlify } from '@ethersproject/bytes'; +import { concat } from '@ethersproject/bytes'; import { Coder, B256Coder, NumberCoder } from '@fuel-ts/abi-coder'; import { ByteArrayCoder } from './byte-array'; +import type { TxPointer } from './tx-pointer'; +import { TxPointerCoder } from './tx-pointer'; import type { UtxoId } from './utxo-id'; import { UtxoIdCoder } from './utxo-id'; @@ -14,24 +16,37 @@ export enum InputType /* u8 */ { export type InputCoin = { type: InputType.Coin; + /** UTXO ID (UtxoId) */ utxoID: UtxoId; + /** Owning address or script hash (b256) */ owner: string; + /** Amount of coins (u64) */ amount: bigint; + /** Asset ID of the coins (b256) */ assetId: string; + + /** Points to the TX whose output is being spent. (TxPointer) */ + txPointer: TxPointer; + /** Index of witness that authorizes spending the coin (u8) */ witnessIndex: number; - /** UTXO being spent must have been created at least this many blocks ago (u64) */ - maturity: bigint; + + /** UTXO being spent must have been created at least this many blocks ago (u32) */ + maturity: number; + /** Length of predicate, in instructions (u16) */ predicateLength: number; + /** Length of predicate input data, in bytes (u16) */ predicateDataLength: number; + /** Predicate bytecode (byte[]) */ predicate: string; + /** Predicate input data (parameters) (byte[]) */ predicateData: string; }; @@ -44,24 +59,13 @@ export class InputCoinCoder extends Coder { encode(value: InputCoin): Uint8Array { const parts: Uint8Array[] = []; - // console.log(`value`, value); - // console.log( - // `new UtxoIdCoder().encode(value.utxoID)`, - // hexlify(new UtxoIdCoder().encode(value.utxoID)) - // ); - parts.push(new UtxoIdCoder().encode(value.utxoID)); parts.push(new B256Coder().encode(value.owner)); parts.push(new NumberCoder('u64').encode(value.amount)); parts.push(new B256Coder().encode(value.assetId)); - - // txPointer - parts.push(new NumberCoder('u16').encode(0)); - parts.push(new NumberCoder('u16').encode(0)); - // txPointer - + parts.push(new TxPointerCoder().encode(value.txPointer)); parts.push(new NumberCoder('u8').encode(value.witnessIndex)); - parts.push(new NumberCoder('u64').encode(value.maturity)); + parts.push(new NumberCoder('u32').encode(value.maturity)); parts.push(new NumberCoder('u16').encode(value.predicateLength)); parts.push(new NumberCoder('u16').encode(value.predicateDataLength)); parts.push(new ByteArrayCoder(value.predicateLength).encode(value.predicate)); @@ -82,17 +86,11 @@ export class InputCoinCoder extends Coder { const amount = decoded; [decoded, o] = new B256Coder().decode(data, o); const assetId = decoded; - - // txPointer - [decoded, o] = new NumberCoder('u16').decode(data, o); - const txPointer = Number(decoded); - [decoded, o] = new NumberCoder('u16').decode(data, o); - const txPointer2 = Number(decoded); - // txPointer - + [decoded, o] = new TxPointerCoder().decode(data, o); + const txPointer = decoded; [decoded, o] = new NumberCoder('u8').decode(data, o); const witnessIndex = Number(decoded); - [decoded, o] = new NumberCoder('u64').decode(data, o); + [decoded, o] = new NumberCoder('u32').decode(data, o); const maturity = decoded; [decoded, o] = new NumberCoder('u16').decode(data, o); [decoded, o] = new NumberCoder('u16').decode(data, o); @@ -110,6 +108,7 @@ export class InputCoinCoder extends Coder { owner, amount, assetId, + txPointer, witnessIndex, maturity, predicateLength, @@ -128,12 +127,19 @@ export class InputCoinCoder extends Coder { export type InputContract = { type: InputType.Contract; + /** UTXO ID (UtxoId) */ utxoID: UtxoId; + /** Root of amount of coins owned by contract before transaction execution (b256) */ balanceRoot: string; + /** State root of contract before transaction execution (b256) */ stateRoot: string; + + /** Points to the TX whose output is being spent. (TxPointer) */ + txPointer: TxPointer; + /** Contract ID (b256) */ contractID: string; }; @@ -149,12 +155,7 @@ export class InputContractCoder extends Coder { parts.push(new UtxoIdCoder().encode(value.utxoID)); parts.push(new B256Coder().encode(value.balanceRoot)); parts.push(new B256Coder().encode(value.stateRoot)); - - // txPointer - parts.push(new NumberCoder('u16').encode(0)); - parts.push(new NumberCoder('u16').encode(0)); - // txPointer - + parts.push(new TxPointerCoder().encode(value.txPointer)); parts.push(new B256Coder().encode(value.contractID)); return concat(parts); @@ -170,14 +171,8 @@ export class InputContractCoder extends Coder { const balanceRoot = decoded; [decoded, o] = new B256Coder().decode(data, o); const stateRoot = decoded; - - // txPointer - [decoded, o] = new NumberCoder('u16').decode(data, o); - const txPointer = Number(decoded); - [decoded, o] = new NumberCoder('u16').decode(data, o); - const txPointer2 = Number(decoded); - // txPointer - + [decoded, o] = new TxPointerCoder().decode(data, o); + const txPointer = decoded; [decoded, o] = new B256Coder().decode(data, o); const contractID = decoded; @@ -187,6 +182,7 @@ export class InputContractCoder extends Coder { utxoID, balanceRoot, stateRoot, + txPointer, contractID, }, o, diff --git a/packages/transactions/src/coders/transaction.test.ts b/packages/transactions/src/coders/transaction.test.ts index 024e709d727..fd08780b6a9 100644 --- a/packages/transactions/src/coders/transaction.test.ts +++ b/packages/transactions/src/coders/transaction.test.ts @@ -6,7 +6,7 @@ import { TransactionCoder, TransactionType } from './transaction'; const B256 = '0xd5579c46dfcc7f18207013e65b44e4cb4e2c2298f4ac457ba8f82743f31e930b'; describe('TransactionCoder', () => { - it('Can encode TransactionScript', () => { + it.only('Can encode TransactionScript', () => { const transaction: Transaction = { type: TransactionType.Script, gasPrice: 0n, @@ -28,7 +28,7 @@ describe('TransactionCoder', () => { const encoded = hexlify(new TransactionCoder().encode(transaction)); expect(encoded).toEqual( - '0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000d5579c46dfcc7f18207013e65b44e4cb4e2c2298f4ac457ba8f82743f31e930b' + '0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000d5579c46dfcc7f18207013e65b44e4cb4e2c2298f4ac457ba8f82743f31e930b' ); const [decoded, offset] = new TransactionCoder().decode(arrayify(encoded), 0); diff --git a/packages/transactions/src/coders/transaction.ts b/packages/transactions/src/coders/transaction.ts index ec9779eaae0..7e698cbd6dd 100644 --- a/packages/transactions/src/coders/transaction.ts +++ b/packages/transactions/src/coders/transaction.ts @@ -24,8 +24,8 @@ export type TransactionScript = { gasPrice: bigint; /** Gas limit for transaction (u64) */ gasLimit: bigint; - /** Block until which tx cannot be included (u64) */ - maturity: bigint; + /** Block until which tx cannot be included (u32) */ + maturity: number; /** Script length, in instructions (u16) */ scriptLength: number; /** Length of script input data, in bytes (u16) */ @@ -58,16 +58,9 @@ export class TransactionScriptCoder extends Coder { + it('can encode TxPointer', () => { + const txPointer: TxPointer = { + blockHeight: 10, + txIndex: 1, + }; + + const encoded = hexlify(new TxPointerCoder().encode(txPointer)); + + expect(encoded).toEqual('0x000000000000000a0000000000000001'); + + const [decoded, offset] = new TxPointerCoder().decode(arrayify(encoded), 0); + + expect(offset).toEqual(16); + expect(decoded).toEqual(txPointer); + }); + it('does not encode bad TxPointer', () => { + const txPointer: TxPointer = { + // @ts-expect-error: Values shouldn't be assignable + blockHeight: B256, + // @ts-expect-error: Values shouldn't be assignable + txIndex: B256, + }; + + expect(() => { + new TxPointerCoder().encode(txPointer); + }).toThrow(); + }); +}); diff --git a/packages/transactions/src/coders/tx-pointer.ts b/packages/transactions/src/coders/tx-pointer.ts new file mode 100644 index 00000000000..4fc31f9df93 --- /dev/null +++ b/packages/transactions/src/coders/tx-pointer.ts @@ -0,0 +1,21 @@ +import { NumberCoder, StructCoder } from '@fuel-ts/abi-coder'; + +export type TxPointer = { + /** Block height (u32) */ + blockHeight: number; + + /** Transaction index (u16) */ + txIndex: number; +}; + +export class TxPointerCoder extends StructCoder<{ + blockHeight: NumberCoder<'u32'>; + txIndex: NumberCoder<'u16'>; +}> { + constructor() { + super('TxPointer', { + blockHeight: new NumberCoder('u32'), + txIndex: new NumberCoder('u16'), + }); + } +} diff --git a/packages/transactions/src/index.ts b/packages/transactions/src/index.ts index 557f88a330c..aadb3c15f53 100644 --- a/packages/transactions/src/index.ts +++ b/packages/transactions/src/index.ts @@ -4,5 +4,6 @@ export * from './coders/receipt'; export * from './coders/storage-slot'; export * from './coders/transaction'; export * from './coders/witness'; +export * from './coders/tx-pointer'; export * from './coders/utxo-id'; export * from './consts'; From 4e8315702dc6eeb2e75bf64a3424a32670a5d168 Mon Sep 17 00:00:00 2001 From: Luiz Felipe Bolsoni Gomes Date: Fri, 19 Aug 2022 13:13:03 -0300 Subject: [PATCH 04/17] fix: purge staticContracts --- .../contract/src/__test__/contract-factory.test.ts | 1 - .../src/transaction-request/transaction-request.ts | 9 --------- packages/transactions/src/coders/transaction.test.ts | 2 -- packages/transactions/src/coders/transaction.ts | 12 ------------ 4 files changed, 24 deletions(-) diff --git a/packages/contract/src/__test__/contract-factory.test.ts b/packages/contract/src/__test__/contract-factory.test.ts index cb7db622c87..8a24a864909 100644 --- a/packages/contract/src/__test__/contract-factory.test.ts +++ b/packages/contract/src/__test__/contract-factory.test.ts @@ -1,4 +1,3 @@ -import { arrayify, hexlify } from '@ethersproject/bytes'; import { Interface } from '@fuel-ts/abi-coder'; import { NativeAssetId } from '@fuel-ts/constants'; import { Provider } from '@fuel-ts/providers'; diff --git a/packages/providers/src/transaction-request/transaction-request.ts b/packages/providers/src/transaction-request/transaction-request.ts index 01fa0cc18b1..1b559e9d1c8 100644 --- a/packages/providers/src/transaction-request/transaction-request.ts +++ b/packages/providers/src/transaction-request/transaction-request.ts @@ -441,8 +441,6 @@ export interface CreateTransactionRequestLike extends BaseTransactionRequestLike bytecodeWitnessIndex?: number; /** Salt */ salt?: BytesLike; - /** List of static contracts */ - staticContracts?: BytesLike[]; /** List of storage slots to initialize */ storageSlots?: TransactionRequestStorageSlot[]; } @@ -461,39 +459,32 @@ export class CreateTransactionRequest extends BaseTransactionRequest { bytecodeWitnessIndex: number; /** Salt */ salt: string; - /** List of static contracts */ - staticContracts: string[]; /** List of storage slots to initialize */ storageSlots: TransactionRequestStorageSlot[]; constructor({ bytecodeWitnessIndex, salt, - staticContracts, storageSlots, ...rest }: CreateTransactionRequestLike = {}) { super(rest); this.bytecodeWitnessIndex = bytecodeWitnessIndex ?? 0; this.salt = hexlify(salt ?? ZeroBytes32); - this.staticContracts = [...(staticContracts?.map((value) => hexlify(value)) ?? [])]; this.storageSlots = [...(storageSlots ?? [])]; } toTransaction(): Transaction { const baseTransaction = this.getBaseTransaction(); const bytecodeWitnessIndex = this.bytecodeWitnessIndex; - const staticContracts = this.staticContracts ?? []; const storageSlots = this.storageSlots?.map(storageSlotify) ?? []; return { type: TransactionType.Create, ...baseTransaction, bytecodeLength: baseTransaction.witnesses[bytecodeWitnessIndex].dataLength / 4, bytecodeWitnessIndex, - staticContractsCount: staticContracts.length, storageSlotsCount: storageSlots.length, salt: this.salt ? hexlify(this.salt) : ZeroBytes32, - staticContracts: staticContracts.map((id) => hexlify(id)), storageSlots, }; } diff --git a/packages/transactions/src/coders/transaction.test.ts b/packages/transactions/src/coders/transaction.test.ts index fd08780b6a9..1a49eb05c00 100644 --- a/packages/transactions/src/coders/transaction.test.ts +++ b/packages/transactions/src/coders/transaction.test.ts @@ -45,13 +45,11 @@ describe('TransactionCoder', () => { maturity: 0n, bytecodeLength: 0, bytecodeWitnessIndex: 0, - staticContractsCount: 0, storageSlotsCount: 0, inputsCount: 0, outputsCount: 0, witnessesCount: 0, salt: B256, - staticContracts: [], storageSlots: [], inputs: [], outputs: [], diff --git a/packages/transactions/src/coders/transaction.ts b/packages/transactions/src/coders/transaction.ts index 7e698cbd6dd..3d85a4581be 100644 --- a/packages/transactions/src/coders/transaction.ts +++ b/packages/transactions/src/coders/transaction.ts @@ -150,8 +150,6 @@ export type TransactionCreate = { bytecodeLength: number; /** Witness index of contract bytecode to create (u8) */ bytecodeWitnessIndex: number; - /** Number of static contracts (u8) */ - staticContractsCount: number; /** Number of storage slots to initialize (u16) */ storageSlotsCount: number; /** Number of inputs (u8) */ @@ -162,8 +160,6 @@ export type TransactionCreate = { witnessesCount: number; /** Salt (b256) */ salt: string; - /** List of static contracts (b256[]) */ - staticContracts: string[]; /** List of inputs (StorageSlot[]) */ storageSlots: StorageSlot[]; /** List of inputs (Input[]) */ @@ -214,22 +210,18 @@ export class TransactionCreateCoder extends Coder Date: Fri, 19 Aug 2022 13:44:34 -0300 Subject: [PATCH 05/17] chore --- .../src/transaction-request/input.ts | 5 +- .../src/coders/transaction.test.ts | 4 +- .../transactions/src/coders/transaction.ts | 28 ++++++ packages/transactions/src/consts.ts | 8 +- services/fuel-core/chainConfig.json | 96 +++++++++---------- 5 files changed, 84 insertions(+), 57 deletions(-) diff --git a/packages/providers/src/transaction-request/input.ts b/packages/providers/src/transaction-request/input.ts index 486e27fd60c..3b49c974129 100644 --- a/packages/providers/src/transaction-request/input.ts +++ b/packages/providers/src/transaction-request/input.ts @@ -82,10 +82,9 @@ export const inputify = (value: TransactionRequestInput): Input => { }, balanceRoot: ZeroBytes32, stateRoot: ZeroBytes32, - txPointer: { - blockHeight: arrayify(value.txPointer)[16], - txIndex: arrayify(value.txPointer)[32], + blockHeight: toNumber(arrayify(value.txPointer).slice(0, 8)), + txIndex: toNumber(arrayify(value.txPointer).slice(8, 16)), }, contractID: hexlify(value.contractId), }; diff --git a/packages/transactions/src/coders/transaction.test.ts b/packages/transactions/src/coders/transaction.test.ts index 1a49eb05c00..0b99248da00 100644 --- a/packages/transactions/src/coders/transaction.test.ts +++ b/packages/transactions/src/coders/transaction.test.ts @@ -11,7 +11,7 @@ describe('TransactionCoder', () => { type: TransactionType.Script, gasPrice: 0n, gasLimit: 0n, - maturity: 0n, + maturity: 0, scriptLength: 0, scriptDataLength: 0, inputsCount: 0, @@ -42,7 +42,7 @@ describe('TransactionCoder', () => { type: TransactionType.Create, gasPrice: 0n, gasLimit: 0n, - maturity: 0n, + maturity: 0, bytecodeLength: 0, bytecodeWitnessIndex: 0, storageSlotsCount: 0, diff --git a/packages/transactions/src/coders/transaction.ts b/packages/transactions/src/coders/transaction.ts index 3d85a4581be..76b4a920113 100644 --- a/packages/transactions/src/coders/transaction.ts +++ b/packages/transactions/src/coders/transaction.ts @@ -20,32 +20,46 @@ export enum TransactionType /* u8 */ { export type TransactionScript = { type: TransactionType.Script; + /** Gas price for transaction (u64) */ gasPrice: bigint; + /** Gas limit for transaction (u64) */ gasLimit: bigint; + /** Block until which tx cannot be included (u32) */ maturity: number; + /** Script length, in instructions (u16) */ scriptLength: number; + /** Length of script input data, in bytes (u16) */ scriptDataLength: number; + /** Number of inputs (u8) */ inputsCount: number; + /** Number of outputs (u8) */ outputsCount: number; + /** Number of witnesses (u8) */ witnessesCount: number; + /** Merkle root of receipts (b256) */ receiptsRoot: string; + /** Script to execute (byte[]) */ script: string; + /** Script input data (parameters) (byte[]) */ scriptData: string; + /** List of inputs (Input[]) */ inputs: Input[]; + /** List of outputs (Output[]) */ outputs: Output[]; + /** List of witnesses (Witness[]) */ witnesses: Witness[]; }; @@ -140,32 +154,46 @@ export class TransactionScriptCoder extends Coder / MAX_GAS_PER_TX); */ -export const MAX_GAS_PER_TX = 100000000n; - -/** Gas charged per byte of the transaction. */ export const GAS_PRICE_FACTOR = 1000000n; -/** Maximum gas per transaction. */ +/** Gas charged per byte of the transaction. */ export const GAS_PER_BYTE = 4n; // TODO: set max script length const diff --git a/services/fuel-core/chainConfig.json b/services/fuel-core/chainConfig.json index 5749dc44394..37d18ee0b62 100644 --- a/services/fuel-core/chainConfig.json +++ b/services/fuel-core/chainConfig.json @@ -8,242 +8,242 @@ "coins": [ { "owner": "0x09c0b2d1a486c439a87bcba6b46a7a1a23f3897cc83a94521a96da5c23bc58db", - "amount": "0x0000FFFFFFFFFFFF", + "amount": "0xFFFFFFFFFFFFFFFF", "asset_id": "0x0000000000000000000000000000000000000000000000000000000000000000" }, { "owner": "0x09c0b2d1a486c439a87bcba6b46a7a1a23f3897cc83a94521a96da5c23bc58db", - "amount": "0x0000FFFFFFFFFFFF", + "amount": "0xFFFFFFFFFFFFFFFF", "asset_id": "0x0101010101010101010101010101010101010101010101010101010101010101" }, { "owner": "0x09c0b2d1a486c439a87bcba6b46a7a1a23f3897cc83a94521a96da5c23bc58db", - "amount": "0x0000FFFFFFFFFFFF", + "amount": "0xFFFFFFFFFFFFFFFF", "asset_id": "0x0202020202020202020202020202020202020202020202020202020202020202" }, { "owner": "0x5d99ee966b42cd8fc7bdd1364b389153a9e78b42b7d4a691470674e817888d4e", - "amount": "0x0000FFFFFFFFFFFF", + "amount": "0xFFFFFFFFFFFFFFFF", "asset_id": "0x0000000000000000000000000000000000000000000000000000000000000000" }, { "owner": "0x5d99ee966b42cd8fc7bdd1364b389153a9e78b42b7d4a691470674e817888d4e", - "amount": "0x0000FFFFFFFFFFFF", + "amount": "0xFFFFFFFFFFFFFFFF", "asset_id": "0x0101010101010101010101010101010101010101010101010101010101010101" }, { "owner": "0x5d99ee966b42cd8fc7bdd1364b389153a9e78b42b7d4a691470674e817888d4e", - "amount": "0x0000FFFFFFFFFFFF", + "amount": "0xFFFFFFFFFFFFFFFF", "asset_id": "0x0202020202020202020202020202020202020202020202020202020202020202" }, { "owner": "0xbdaad6a89e073e177895b3e5a9ccd15806749eda134a6438dae32fc5b6601f3f", - "amount": "0x0000FFFFFFFFFFFF", + "amount": "0xFFFFFFFFFFFFFFFF", "asset_id": "0x0000000000000000000000000000000000000000000000000000000000000000" }, { "owner": "0xbdaad6a89e073e177895b3e5a9ccd15806749eda134a6438dae32fc5b6601f3f", - "amount": "0x0000FFFFFFFFFFFF", + "amount": "0xFFFFFFFFFFFFFFFF", "asset_id": "0x0101010101010101010101010101010101010101010101010101010101010101" }, { "owner": "0xbdaad6a89e073e177895b3e5a9ccd15806749eda134a6438dae32fc5b6601f3f", - "amount": "0x0000FFFFFFFFFFFF", + "amount": "0xFFFFFFFFFFFFFFFF", "asset_id": "0x0202020202020202020202020202020202020202020202020202020202020202" }, { "owner": "0x95a7aa6cc32743f8706c40ef49a7423b47da763bb4bbc055b1f07254dc729036", - "amount": "0x0000FFFFFFFFFFFF", + "amount": "0xFFFFFFFFFFFFFFFF", "asset_id": "0x0000000000000000000000000000000000000000000000000000000000000000" }, { "owner": "0x95a7aa6cc32743f8706c40ef49a7423b47da763bb4bbc055b1f07254dc729036", - "amount": "0x0000FFFFFFFFFFFF", + "amount": "0xFFFFFFFFFFFFFFFF", "asset_id": "0x0101010101010101010101010101010101010101010101010101010101010101" }, { "owner": "0x95a7aa6cc32743f8706c40ef49a7423b47da763bb4bbc055b1f07254dc729036", - "amount": "0x0000FFFFFFFFFFFF", + "amount": "0xFFFFFFFFFFFFFFFF", "asset_id": "0x0202020202020202020202020202020202020202020202020202020202020202" }, { "owner": "0xcee104acd38b940c8f1c62c6d7ea00a0ad2241d6dee0509a4bf27297508870d3", - "amount": "0x0000FFFFFFFFFFFF", + "amount": "0xFFFFFFFFFFFFFFFF", "asset_id": "0x0000000000000000000000000000000000000000000000000000000000000000" }, { "owner": "0xcee104acd38b940c8f1c62c6d7ea00a0ad2241d6dee0509a4bf27297508870d3", - "amount": "0x0000FFFFFFFFFFFF", + "amount": "0xFFFFFFFFFFFFFFFF", "asset_id": "0x0101010101010101010101010101010101010101010101010101010101010101" }, { "owner": "0xcee104acd38b940c8f1c62c6d7ea00a0ad2241d6dee0509a4bf27297508870d3", - "amount": "0x0000FFFFFFFFFFFF", + "amount": "0xFFFFFFFFFFFFFFFF", "asset_id": "0x0202020202020202020202020202020202020202020202020202020202020202" }, { "owner": "0x7e3626e306588eba79cafab73f0709e55ab8f4bdfe8c8b75034a430fc56ece89", - "amount": "0x0000FFFFFFFFFFFF", + "amount": "0xFFFFFFFFFFFFFFFF", "asset_id": "0x0000000000000000000000000000000000000000000000000000000000000000" }, { "owner": "0x7e3626e306588eba79cafab73f0709e55ab8f4bdfe8c8b75034a430fc56ece89", - "amount": "0x0000FFFFFFFFFFFF", + "amount": "0xFFFFFFFFFFFFFFFF", "asset_id": "0x0101010101010101010101010101010101010101010101010101010101010101" }, { "owner": "0x7e3626e306588eba79cafab73f0709e55ab8f4bdfe8c8b75034a430fc56ece89", - "amount": "0x0000FFFFFFFFFFFF", + "amount": "0xFFFFFFFFFFFFFFFF", "asset_id": "0x0202020202020202020202020202020202020202020202020202020202020202" }, { "owner": "0x1c31df52b6df56407dd95f83082e8beb9cfc9532ac111d5bd8491651d95ba775", - "amount": "0x0000FFFFFFFFFFFF", + "amount": "0xFFFFFFFFFFFFFFFF", "asset_id": "0x0000000000000000000000000000000000000000000000000000000000000000" }, { "owner": "0x1c31df52b6df56407dd95f83082e8beb9cfc9532ac111d5bd8491651d95ba775", - "amount": "0x0000FFFFFFFFFFFF", + "amount": "0xFFFFFFFFFFFFFFFF", "asset_id": "0x0101010101010101010101010101010101010101010101010101010101010101" }, { "owner": "0x1c31df52b6df56407dd95f83082e8beb9cfc9532ac111d5bd8491651d95ba775", - "amount": "0x0000FFFFFFFFFFFF", + "amount": "0xFFFFFFFFFFFFFFFF", "asset_id": "0x0202020202020202020202020202020202020202020202020202020202020202" }, { "owner": "0x09dd7a49174d6fcc9f4c6f7942c18060a935ddd03ee69b594189b8c3581276ea", - "amount": "0x0000FFFFFFFFFFFF", + "amount": "0xFFFFFFFFFFFFFFFF", "asset_id": "0x0000000000000000000000000000000000000000000000000000000000000000" }, { "owner": "0x09dd7a49174d6fcc9f4c6f7942c18060a935ddd03ee69b594189b8c3581276ea", - "amount": "0x0000FFFFFFFFFFFF", + "amount": "0xFFFFFFFFFFFFFFFF", "asset_id": "0x0101010101010101010101010101010101010101010101010101010101010101" }, { "owner": "0x09dd7a49174d6fcc9f4c6f7942c18060a935ddd03ee69b594189b8c3581276ea", - "amount": "0x0000FFFFFFFFFFFF", + "amount": "0xFFFFFFFFFFFFFFFF", "asset_id": "0x0202020202020202020202020202020202020202020202020202020202020202" }, { "owner": "0x86604282dc604481b809845be49667607c470644f6822fc01eb0d22f167e08cf", - "amount": "0x0000FFFFFFFFFFFF", + "amount": "0xFFFFFFFFFFFFFFFF", "asset_id": "0x0000000000000000000000000000000000000000000000000000000000000000" }, { "owner": "0x86604282dc604481b809845be49667607c470644f6822fc01eb0d22f167e08cf", - "amount": "0x0000FFFFFFFFFFFF", + "amount": "0xFFFFFFFFFFFFFFFF", "asset_id": "0x0101010101010101010101010101010101010101010101010101010101010101" }, { "owner": "0x86604282dc604481b809845be49667607c470644f6822fc01eb0d22f167e08cf", - "amount": "0x0000FFFFFFFFFFFF", + "amount": "0xFFFFFFFFFFFFFFFF", "asset_id": "0x0202020202020202020202020202020202020202020202020202020202020202" }, { "owner": "0xbca334a06d19db5041c78fe2f465b07be5bec828f38b7796b2877e7d1542c950", - "amount": "0x0000FFFFFFFFFFFF", + "amount": "0xFFFFFFFFFFFFFFFF", "asset_id": "0x0000000000000000000000000000000000000000000000000000000000000000" }, { "owner": "0xbca334a06d19db5041c78fe2f465b07be5bec828f38b7796b2877e7d1542c950", - "amount": "0x0000FFFFFFFFFFFF", + "amount": "0xFFFFFFFFFFFFFFFF", "asset_id": "0x0101010101010101010101010101010101010101010101010101010101010101" }, { "owner": "0xbca334a06d19db5041c78fe2f465b07be5bec828f38b7796b2877e7d1542c950", - "amount": "0x0000FFFFFFFFFFFF", + "amount": "0xFFFFFFFFFFFFFFFF", "asset_id": "0x0202020202020202020202020202020202020202020202020202020202020202" }, { "owner": "0xbd9a1dc8d3ec3521c43f6c2c01611b4d0204c7610204ff0178488c8738a30bd2", - "amount": "0x0000FFFFFFFFFFFF", + "amount": "0xFFFFFFFFFFFFFFFF", "asset_id": "0x0000000000000000000000000000000000000000000000000000000000000000" }, { "owner": "0xbd9a1dc8d3ec3521c43f6c2c01611b4d0204c7610204ff0178488c8738a30bd2", - "amount": "0x0000FFFFFFFFFFFF", + "amount": "0xFFFFFFFFFFFFFFFF", "asset_id": "0x0101010101010101010101010101010101010101010101010101010101010101" }, { "owner": "0xbd9a1dc8d3ec3521c43f6c2c01611b4d0204c7610204ff0178488c8738a30bd2", - "amount": "0x0000FFFFFFFFFFFF", + "amount": "0xFFFFFFFFFFFFFFFF", "asset_id": "0x0202020202020202020202020202020202020202020202020202020202020202" }, { "owner": "0xb32197cf75efe05bf453c26178139f09b391582065549c1422bc92555ecffb64", - "amount": "0x0000FFFFFFFFFFFF", + "amount": "0xFFFFFFFFFFFFFFFF", "asset_id": "0x0000000000000000000000000000000000000000000000000000000000000000" }, { "owner": "0xb32197cf75efe05bf453c26178139f09b391582065549c1422bc92555ecffb64", - "amount": "0x0000FFFFFFFFFFFF", + "amount": "0xFFFFFFFFFFFFFFFF", "asset_id": "0x0101010101010101010101010101010101010101010101010101010101010101" }, { "owner": "0xb32197cf75efe05bf453c26178139f09b391582065549c1422bc92555ecffb64", - "amount": "0x0000FFFFFFFFFFFF", + "amount": "0xFFFFFFFFFFFFFFFF", "asset_id": "0x0202020202020202020202020202020202020202020202020202020202020202" }, { "owner": "0x3b24509ed4ab3c7959f5c9391c1445c59290cdb5f13d6f780922f376b7029f30", - "amount": "0x0000FFFFFFFFFFFF", + "amount": "0xFFFFFFFFFFFFFFFF", "asset_id": "0x0000000000000000000000000000000000000000000000000000000000000000" }, { "owner": "0x3b24509ed4ab3c7959f5c9391c1445c59290cdb5f13d6f780922f376b7029f30", - "amount": "0x0000FFFFFFFFFFFF", + "amount": "0xFFFFFFFFFFFFFFFF", "asset_id": "0x0101010101010101010101010101010101010101010101010101010101010101" }, { "owner": "0x3b24509ed4ab3c7959f5c9391c1445c59290cdb5f13d6f780922f376b7029f30", - "amount": "0x0000FFFFFFFFFFFF", + "amount": "0xFFFFFFFFFFFFFFFF", "asset_id": "0x0202020202020202020202020202020202020202020202020202020202020202" }, { "owner": "0x77c6f40b7da70d885f68efaad7c661327482a63ea10dcb4271de819438254ae1", - "amount": "0x0000FFFFFFFFFFFF", + "amount": "0xFFFFFFFFFFFFFFFF", "asset_id": "0x0000000000000000000000000000000000000000000000000000000000000000" }, { "owner": "0x77c6f40b7da70d885f68efaad7c661327482a63ea10dcb4271de819438254ae1", - "amount": "0x0000FFFFFFFFFFFF", + "amount": "0xFFFFFFFFFFFFFFFF", "asset_id": "0x0101010101010101010101010101010101010101010101010101010101010101" }, { "owner": "0x77c6f40b7da70d885f68efaad7c661327482a63ea10dcb4271de819438254ae1", - "amount": "0x0000FFFFFFFFFFFF", + "amount": "0xFFFFFFFFFFFFFFFF", "asset_id": "0x0202020202020202020202020202020202020202020202020202020202020202" }, { "owner": "0x6a2c4691c547c43924650dbd30620b184b5fe3fb6dbe5c4446110b08f6f405bf", - "amount": "0x0000FFFFFFFFFFFF", + "amount": "0xFFFFFFFFFFFFFFFF", "asset_id": "0x0000000000000000000000000000000000000000000000000000000000000000" }, { "owner": "0x6a2c4691c547c43924650dbd30620b184b5fe3fb6dbe5c4446110b08f6f405bf", - "amount": "0x0000FFFFFFFFFFFF", + "amount": "0xFFFFFFFFFFFFFFFF", "asset_id": "0x0101010101010101010101010101010101010101010101010101010101010101" }, { "owner": "0x6a2c4691c547c43924650dbd30620b184b5fe3fb6dbe5c4446110b08f6f405bf", - "amount": "0x0000FFFFFFFFFFFF", + "amount": "0xFFFFFFFFFFFFFFFF", "asset_id": "0x0202020202020202020202020202020202020202020202020202020202020202" }, { "owner": "0x49075a7538e2c88ebe1926ce4d898198a2a4e790d14512943a9864bc536b3c82", - "amount": "0x0000FFFFFFFFFFFF", + "amount": "0xFFFFFFFFFFFFFFFF", "asset_id": "0x0000000000000000000000000000000000000000000000000000000000000000" }, { "owner": "0x49075a7538e2c88ebe1926ce4d898198a2a4e790d14512943a9864bc536b3c82", - "amount": "0x0000FFFFFFFFFFFF", + "amount": "0xFFFFFFFFFFFFFFFF", "asset_id": "0x0101010101010101010101010101010101010101010101010101010101010101" }, { "owner": "0x49075a7538e2c88ebe1926ce4d898198a2a4e790d14512943a9864bc536b3c82", - "amount": "0x0000FFFFFFFFFFFF", + "amount": "0xFFFFFFFFFFFFFFFF", "asset_id": "0x0202020202020202020202020202020202020202020202020202020202020202" } ] From 746d488ed8a38abef9512753cb9d47b0788f5bf2 Mon Sep 17 00:00:00 2001 From: Luiz Felipe Bolsoni Gomes Date: Fri, 19 Aug 2022 17:49:03 -0300 Subject: [PATCH 06/17] fix: tests --- packages/testcases/src/sendTransaction.json | 1 + packages/testcases/src/signTransaction.json | 5 +++-- packages/transactions/src/coders/input.test.ts | 14 +++++++++++--- .../transactions/src/coders/transaction.test.ts | 4 ++-- 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/packages/testcases/src/sendTransaction.json b/packages/testcases/src/sendTransaction.json index d4c79ad48d3..b55fc738146 100644 --- a/packages/testcases/src/sendTransaction.json +++ b/packages/testcases/src/sendTransaction.json @@ -13,6 +13,7 @@ "amount": "0x01", "owner": "0xf1e92c42b90934aa6372e30bc568a326f6e66a1a0288595e6e3fbd392a4f3e6e", "maturity": 0, + "txPointer": "0x00000000000000000000000000000000", "witnessIndex": 0, "predicate": "0x", "predicateData": "0x" diff --git a/packages/testcases/src/signTransaction.json b/packages/testcases/src/signTransaction.json index 814dcabe980..e6a17f82357 100644 --- a/packages/testcases/src/signTransaction.json +++ b/packages/testcases/src/signTransaction.json @@ -13,6 +13,7 @@ "amount": "0x989680", "owner": "0xf1e92c42b90934aa6372e30bc568a326f6e66a1a0288595e6e3fbd392a4f3e6e", "maturity": 0, + "txPointer": "0x00000000000000000000000000000000", "witnessIndex": 0, "predicate": "0x", "predicateData": "0x" @@ -31,6 +32,6 @@ "privateKey": "0x5f70feeff1f229e4a95e1056e8b4d80d0b24b565674860cc213bdb07127ce1b1", "publicKey": "0x2f34bc0df4db0ec391792cedb05768832b49b1aa3a2dd8c30054d1af00f67d00b74b7acbbf3087c8e0b1a4c343db50aa471d21f278ff5ce09f07795d541fb47e", "address": "0xf1e92c42b90934aa6372e30bc568a326f6e66a1a0288595e6e3fbd392a4f3e6e", - "hashedTransaction": "0xabda624d33e5e15a34648e5d348b8fd4e4689d7fe01be4784d1040e9c374b506", - "signedTransaction": "0xa1287a24af13fc102cb9e60988b558d5575d7870032f64bafcc2deda2c99125fb25eca55a29a169de156cb30700965e2b26278fcc7ad375bc720440ea50ba3cb" + "hashedTransaction": "0xa60b5f900f07585e0a6e542c962286ca7ff2b8e7927a6be132289fec7567fa82", + "signedTransaction": "0x34482a581d1fe01ba84900581f5321a8b7d4ec65c3e7ca0de318ff8fcf45eb2c793c4b99e96400673e24b81b7aa47f042cad658f05a84e2f96f365eb0ce5a511" } diff --git a/packages/transactions/src/coders/input.test.ts b/packages/transactions/src/coders/input.test.ts index f82e2ae66e4..07b61683623 100644 --- a/packages/transactions/src/coders/input.test.ts +++ b/packages/transactions/src/coders/input.test.ts @@ -14,17 +14,21 @@ describe('InputCoder', () => { amount: 0n, assetId: B256, witnessIndex: 0, - maturity: 0n, + maturity: 0, predicateLength: 0, predicateDataLength: 0, predicate: '0x', predicateData: '0x', + txPointer: { + blockHeight: 0, + txIndex: 0, + }, }; const encoded = hexlify(new InputCoder().encode(input)); expect(encoded).toEqual( - '0x0000000000000000d5579c46dfcc7f18207013e65b44e4cb4e2c2298f4ac457ba8f82743f31e930b0000000000000000d5579c46dfcc7f18207013e65b44e4cb4e2c2298f4ac457ba8f82743f31e930b0000000000000000d5579c46dfcc7f18207013e65b44e4cb4e2c2298f4ac457ba8f82743f31e930b0000000000000000000000000000000000000000000000000000000000000000' + '0x0000000000000000d5579c46dfcc7f18207013e65b44e4cb4e2c2298f4ac457ba8f82743f31e930b0000000000000000d5579c46dfcc7f18207013e65b44e4cb4e2c2298f4ac457ba8f82743f31e930b0000000000000000d5579c46dfcc7f18207013e65b44e4cb4e2c2298f4ac457ba8f82743f31e930b000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000' ); const [decoded, offset] = new InputCoder().decode(arrayify(encoded), 0); @@ -40,12 +44,16 @@ describe('InputCoder', () => { balanceRoot: B256, stateRoot: B256, contractID: B256, + txPointer: { + blockHeight: 0, + txIndex: 0, + }, }; const encoded = hexlify(new InputCoder().encode(input)); expect(encoded).toEqual( - '0x0000000000000001d5579c46dfcc7f18207013e65b44e4cb4e2c2298f4ac457ba8f82743f31e930b0000000000000000d5579c46dfcc7f18207013e65b44e4cb4e2c2298f4ac457ba8f82743f31e930bd5579c46dfcc7f18207013e65b44e4cb4e2c2298f4ac457ba8f82743f31e930bd5579c46dfcc7f18207013e65b44e4cb4e2c2298f4ac457ba8f82743f31e930b' + '0x0000000000000001d5579c46dfcc7f18207013e65b44e4cb4e2c2298f4ac457ba8f82743f31e930b0000000000000000d5579c46dfcc7f18207013e65b44e4cb4e2c2298f4ac457ba8f82743f31e930bd5579c46dfcc7f18207013e65b44e4cb4e2c2298f4ac457ba8f82743f31e930b00000000000000000000000000000000d5579c46dfcc7f18207013e65b44e4cb4e2c2298f4ac457ba8f82743f31e930b' ); const [decoded, offset] = new InputCoder().decode(arrayify(encoded), 0); diff --git a/packages/transactions/src/coders/transaction.test.ts b/packages/transactions/src/coders/transaction.test.ts index 0b99248da00..053db540130 100644 --- a/packages/transactions/src/coders/transaction.test.ts +++ b/packages/transactions/src/coders/transaction.test.ts @@ -6,7 +6,7 @@ import { TransactionCoder, TransactionType } from './transaction'; const B256 = '0xd5579c46dfcc7f18207013e65b44e4cb4e2c2298f4ac457ba8f82743f31e930b'; describe('TransactionCoder', () => { - it.only('Can encode TransactionScript', () => { + it('Can encode TransactionScript', () => { const transaction: Transaction = { type: TransactionType.Script, gasPrice: 0n, @@ -59,7 +59,7 @@ describe('TransactionCoder', () => { const encoded = hexlify(new TransactionCoder().encode(transaction)); expect(encoded).toEqual( - '0x000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000d5579c46dfcc7f18207013e65b44e4cb4e2c2298f4ac457ba8f82743f31e930b' + '0x0000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000d5579c46dfcc7f18207013e65b44e4cb4e2c2298f4ac457ba8f82743f31e930b' ); const [decoded, offset] = new TransactionCoder().decode(arrayify(encoded), 0); From 7d5650e01a0b3c64f4febf568c656d0dde46fba5 Mon Sep 17 00:00:00 2001 From: Luiz Felipe Bolsoni Gomes Date: Fri, 19 Aug 2022 18:34:26 -0300 Subject: [PATCH 07/17] chore: lint --- packages/contract/src/contracts/contract-factory.ts | 2 -- packages/providers/src/transaction-request/input.ts | 2 +- packages/transactions/src/coders/transaction.ts | 2 +- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/packages/contract/src/contracts/contract-factory.ts b/packages/contract/src/contracts/contract-factory.ts index 8a58fc85ba7..28f16231b5d 100644 --- a/packages/contract/src/contracts/contract-factory.ts +++ b/packages/contract/src/contracts/contract-factory.ts @@ -1,9 +1,7 @@ import type { BytesLike } from '@ethersproject/bytes'; -import { hexlify } from '@ethersproject/bytes'; import { Logger } from '@ethersproject/logger'; import { Interface } from '@fuel-ts/abi-coder'; import type { JsonAbi } from '@fuel-ts/abi-coder'; -import { ZeroBytes32 } from '@fuel-ts/constants'; import { randomBytes } from '@fuel-ts/keystore'; import type { CreateTransactionRequestLike } from '@fuel-ts/providers'; import { Provider, CreateTransactionRequest } from '@fuel-ts/providers'; diff --git a/packages/providers/src/transaction-request/input.ts b/packages/providers/src/transaction-request/input.ts index 3b49c974129..b70544d4ce5 100644 --- a/packages/providers/src/transaction-request/input.ts +++ b/packages/providers/src/transaction-request/input.ts @@ -3,7 +3,7 @@ import { arrayify, hexlify } from '@ethersproject/bytes'; import { ZeroBytes32 } from '@fuel-ts/constants'; import type { BigNumberish } from '@fuel-ts/math'; import { toNumber } from '@fuel-ts/math'; -import type { Input, TxPointer } from '@fuel-ts/transactions'; +import type { Input } from '@fuel-ts/transactions'; import { InputType } from '@fuel-ts/transactions'; export type CoinTransactionRequestInput = { diff --git a/packages/transactions/src/coders/transaction.ts b/packages/transactions/src/coders/transaction.ts index 76b4a920113..fef4faaf66d 100644 --- a/packages/transactions/src/coders/transaction.ts +++ b/packages/transactions/src/coders/transaction.ts @@ -1,6 +1,6 @@ /* eslint-disable max-classes-per-file */ -import { concat, hexlify } from '@ethersproject/bytes'; +import { concat } from '@ethersproject/bytes'; import { Coder, ArrayCoder, B256Coder, NumberCoder } from '@fuel-ts/abi-coder'; import { ByteArrayCoder } from './byte-array'; From 5855d0fd84b714f661db11594bf5188ef4760871 Mon Sep 17 00:00:00 2001 From: Luiz Felipe Bolsoni Gomes Date: Fri, 19 Aug 2022 18:51:46 -0300 Subject: [PATCH 08/17] chore --- packages/providers/src/provider.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/providers/src/provider.ts b/packages/providers/src/provider.ts index d3c57467251..83faac07fa1 100644 --- a/packages/providers/src/provider.ts +++ b/packages/providers/src/provider.ts @@ -297,8 +297,8 @@ export default class Provider { const gasUsed = multiply(getGasUsedFromReceipts(receipts), margin); const byteSize = transactionRequest.chargeableByteSize(); const gasFee = calculatePriceWithFactor(gasUsed, gasPrice, GAS_PRICE_FACTOR); - const gasPerBytePrice = multiply(GAS_PER_BYTE, gasPrice); - const byteFee = calculatePriceWithFactor(byteSize, gasPerBytePrice, GAS_PRICE_FACTOR); + const gasBytePrice = multiply(GAS_PER_BYTE, gasPrice); + const byteFee = calculatePriceWithFactor(byteSize, gasBytePrice, GAS_PRICE_FACTOR); return { minGasPrice, From 771e5ee027713852de80ad235513bfe044836305 Mon Sep 17 00:00:00 2001 From: Luiz Estacio Date: Wed, 31 Aug 2022 17:19:32 -0300 Subject: [PATCH 09/17] refact: improve setup contract utils --- .../call-test-contract.test.ts | 154 ++++++++---------- .../contract/src/__test__/contract.test.ts | 62 ++++--- packages/contract/src/__test__/test-utils.ts | 24 ++- 3 files changed, 122 insertions(+), 118 deletions(-) diff --git a/packages/contract/src/__test__/call-test-contract/call-test-contract.test.ts b/packages/contract/src/__test__/call-test-contract/call-test-contract.test.ts index 19b7b4146db..568e7a5958b 100644 --- a/packages/contract/src/__test__/call-test-contract/call-test-contract.test.ts +++ b/packages/contract/src/__test__/call-test-contract/call-test-contract.test.ts @@ -1,54 +1,24 @@ -import type { Interface, JsonAbi } from '@fuel-ts/abi-coder'; import { NativeAssetId } from '@fuel-ts/constants'; -import { Provider } from '@fuel-ts/providers'; -import type { Wallet } from '@fuel-ts/wallet'; -import { TestUtils } from '@fuel-ts/wallet'; import { readFileSync } from 'fs'; import { join } from 'path'; -import type Contract from '../../contracts/contract'; -import ContractFactory from '../../contracts/contract-factory'; +import { createSetupConfig } from '../test-utils'; import abiJSON from './out/debug/call-test-flat-abi.json'; const contractBytecode = readFileSync(join(__dirname, './out/debug/call-test.bin')); -let contractInstance: Contract; -const deployContract = async (factory: ContractFactory, useCache: boolean = true) => { - if (contractInstance && useCache) return contractInstance; - if (!useCache) { - return factory.deployContract({ - gasPrice: 1, - }); - } - contractInstance = await factory.deployContract(); - return contractInstance; -}; - -let walletInstance: Wallet; -const createWallet = async () => { - if (walletInstance) return walletInstance; - const provider = new Provider('http://127.0.0.1:4000/graphql'); - walletInstance = await TestUtils.generateTestWallet(provider, [ - [5_000_000, NativeAssetId], - [5_000_000, '0x0101010101010101010101010101010101010101010101010101010101010101'], - ]); - return walletInstance; -}; - -export const setup = async (abi: JsonAbi | Interface = abiJSON, useCache: boolean = true) => { - // Create wallet - const wallet = await createWallet(); - const factory = new ContractFactory(contractBytecode, abi, wallet); - const contract = await deployContract(factory, useCache); - return contract; -}; +const setupContract = createSetupConfig({ + contractBytecode, + abi: abiJSON, + cache: true, +}); const U64_MAX = 2n ** 64n - 1n; describe('CallTestContract', () => { it.each([0n, 1337n, U64_MAX - 1n])('can call a contract with u64 (%p)', async (num) => { - const contract = await setup(); + const contract = await setupContract(); const { value } = await contract.functions.foo(num).call(); expect(value).toEqual(num + 1n); }); @@ -61,14 +31,14 @@ describe('CallTestContract', () => { [{ a: false, b: U64_MAX - 1n }], [{ a: true, b: U64_MAX - 1n }], ])('can call a contract with structs (%p)', async (struct) => { - const contract = await setup(); + const contract = await setupContract(); const { value } = await contract.functions.boo(struct).call(); expect(value.a).toEqual(!struct.a); expect(value.b).toEqual(struct.b + 1n); }); it('can call a function with empty arguments', async () => { - const contract = await setup(); + const contract = await setupContract(); const { value: value0 } = await contract.functions.barfoo(0).call(); expect(value0).toEqual(63n); @@ -78,25 +48,29 @@ describe('CallTestContract', () => { }); it('function with empty return output configured should resolve undefined', async () => { - const contract = await setup([ - { - type: 'function', - name: 'return_void', - outputs: [{ type: '()', name: 'foo' }], - }, - ]); + const contract = await setupContract({ + abi: [ + { + type: 'function', + name: 'return_void', + outputs: [{ type: '()', name: 'foo' }], + }, + ], + }); const { value } = await contract.functions.return_void().call(); expect(value).toEqual(undefined); }); it('function with empty return should resolve undefined', async () => { - const contract = await setup([ - { - type: 'function', - name: 'return_void', - }, - ]); + const contract = await setupContract({ + abi: [ + { + type: 'function', + name: 'return_void', + }, + ], + }); // Call method with no params but with no result and no value on config const { value } = await await contract.functions.return_void().call(); @@ -171,7 +145,7 @@ describe('CallTestContract', () => { ])( `Test call with multiple arguments and different types -> %s`, async (method, { values, expected }) => { - const contract = await setup(); + const contract = await setupContract(); const { value } = await contract.functions[method](...values).call(); @@ -180,17 +154,19 @@ describe('CallTestContract', () => { ); it('Forward amount value on contract call', async () => { - const contract = await setup([ - { - type: 'function', - name: 'return_context_amount', - outputs: [ - { - type: 'u64', - }, - ], - }, - ]); + const contract = await setupContract({ + abi: [ + { + type: 'function', + name: 'return_context_amount', + outputs: [ + { + type: 'u64', + }, + ], + }, + ], + }); const { value } = await contract.functions .return_context_amount() .callParams({ @@ -201,17 +177,19 @@ describe('CallTestContract', () => { }); it('Forward asset_id on contract call', async () => { - const contract = await setup([ - { - type: 'function', - name: 'return_context_asset', - outputs: [ - { - type: 'b256', - }, - ], - }, - ]); + const contract = await setupContract({ + abi: [ + { + type: 'function', + name: 'return_context_amount', + outputs: [ + { + type: 'u64', + }, + ], + }, + ], + }); const assetId = '0x0101010101010101010101010101010101010101010101010101010101010101'; const { value } = await contract.functions @@ -224,17 +202,19 @@ describe('CallTestContract', () => { }); it('Forward asset_id on contract simulate call', async () => { - const contract = await setup([ - { - type: 'function', - name: 'return_context_asset', - outputs: [ - { - type: 'b256', - }, - ], - }, - ]); + const contract = await setupContract({ + abi: [ + { + type: 'function', + name: 'return_context_asset', + outputs: [ + { + type: 'b256', + }, + ], + }, + ], + }); const assetId = '0x0101010101010101010101010101010101010101010101010101010101010101'; const { value } = await contract.functions @@ -247,7 +227,7 @@ describe('CallTestContract', () => { }); it('can make multiple calls', async () => { - const contract = await setup(); + const contract = await setupContract(); const num = 1337n; const numC = 10n; diff --git a/packages/contract/src/__test__/contract.test.ts b/packages/contract/src/__test__/contract.test.ts index 1e9b890c32c..6013dc5c707 100644 --- a/packages/contract/src/__test__/contract.test.ts +++ b/packages/contract/src/__test__/contract.test.ts @@ -3,10 +3,22 @@ import { NativeAssetId, ZeroBytes32 } from '@fuel-ts/constants'; import { multiply } from '@fuel-ts/math'; import { Provider } from '@fuel-ts/providers'; import { TestUtils } from '@fuel-ts/wallet'; +import { readFileSync } from 'fs'; +import { join } from 'path'; import Contract from '../contracts/contract'; -import { setup } from './call-test-contract/call-test-contract.test'; +import abiJSON from './call-test-contract/out/debug/call-test-flat-abi.json'; +import { createSetupConfig } from './test-utils'; + +const contractBytecode = readFileSync( + join(__dirname, './call-test-contract/out/debug/call-test.bin') +); + +const setupContract = createSetupConfig({ + contractBytecode, + abi: abiJSON, +}); const jsonFragment = { type: 'function', @@ -85,7 +97,7 @@ describe('Contract', () => { }); it('should fail to execute call if gasLimit is too low', async () => { - const contract = await setup(); + const contract = await setupContract(); let failed; try { @@ -103,8 +115,10 @@ describe('Contract', () => { }); it('adds multiple contracts on invocation', async () => { - const contract = await setup(); - const otherContract = await setup(undefined, false); + const contract = await setupContract(); + const otherContract = await setupContract({ + cache: false, + }); const scope = contract.functions .call_external_foo(1336, otherContract.id) @@ -125,8 +139,10 @@ describe('Contract', () => { }); it('adds multiple contracts on multicalls', async () => { - const contract = await setup(); - const otherContract = await setup(undefined, false); + const contract = await setupContract(); + const otherContract = await setupContract({ + cache: false, + }); const scope = contract .multiCall([ @@ -150,7 +166,7 @@ describe('Contract', () => { }); it('submits multiple calls', async () => { - const contract = await setup(); + const contract = await setupContract(); const { value: results } = await contract .multiCall([contract.functions.foo(1336), contract.functions.foo(1336)]) @@ -159,7 +175,7 @@ describe('Contract', () => { }); it('should fail to execute multiple calls if gasLimit is too low', async () => { - const contract = await setup(); + const contract = await setupContract(); let failed; try { @@ -177,8 +193,8 @@ describe('Contract', () => { }); it('adds multiple contracts on multicalls', async () => { - const contract = await setup(); - const otherContract = await setup(undefined, false); + const contract = await setupContract(); + const otherContract = await setupContract({ cache: true }); const scope = contract .multiCall([contract.functions.foo(1336)]) @@ -199,7 +215,7 @@ describe('Contract', () => { }); it('dryRuns multiple calls', async () => { - const contract = await setup(); + const contract = await setupContract(); const { value: results } = await contract .multiCall([contract.functions.foo(1336), contract.functions.foo(1336)]) @@ -208,7 +224,7 @@ describe('Contract', () => { }); it('simulates multiple calls', async () => { - const contract = await setup(); + const contract = await setupContract(); const { value, callResult, gasUsed } = await contract .multiCall([contract.functions.foo(1336), contract.functions.foo(1336)]) @@ -219,7 +235,7 @@ describe('Contract', () => { }); it('Returns gasUsed and transactionId', async () => { - const contract = await setup(); + const contract = await setupContract(); const { transactionId, gasUsed } = await contract .multiCall([contract.functions.foo(1336), contract.functions.foo(1336)]) @@ -229,7 +245,7 @@ describe('Contract', () => { }); it('Single call with forwarding a alt token', async () => { - const contract = await setup(); + const contract = await setupContract(); const { value } = await contract.functions .return_context_amount() .callParams({ @@ -245,7 +261,7 @@ describe('Contract', () => { }); it('MultiCall with multiple forwarding', async () => { - const contract = await setup(); + const contract = await setupContract(); const { value } = await contract .multiCall([ @@ -268,7 +284,7 @@ describe('Contract', () => { }); it('Check if gas per call is lower than transaction', async () => { - const contract = await setup(); + const contract = await setupContract(); await expect(async () => { await contract @@ -293,7 +309,7 @@ describe('Contract', () => { }); it('can forward gas to multicall calls', async () => { - const contract = await setup(); + const contract = await setupContract(); const { value } = await contract .multiCall([ @@ -323,7 +339,7 @@ describe('Contract', () => { }); it('Get transaction cost', async () => { - const contract = await setup(); + const contract = await setupContract(); const invocationScope = contract.multiCall([ contract.functions.return_context_amount().callParams({ @@ -350,7 +366,7 @@ describe('Contract', () => { }); it('Get transaction cost with gasPrice 1', async () => { - const contract = await setup(); + const contract = await setupContract(); const invocationScope = contract .multiCall([ @@ -385,7 +401,7 @@ describe('Contract', () => { }); it('Get transaction cost with gasPrice 2', async () => { - const contract = await setup(); + const contract = await setupContract(); const invocationScope = contract.multiCall([ contract.functions.return_context_amount().callParams({ @@ -418,7 +434,7 @@ describe('Contract', () => { }); it('Fail before submit if gasLimit is lower than gasUsed', async () => { - const contract = await setup(); + const contract = await setupContract(); const invocationScope = contract.functions.return_context_amount().callParams({ forward: [100, NativeAssetId], @@ -438,7 +454,7 @@ describe('Contract', () => { }); it('calls array functions', async () => { - const contract = await setup(); + const contract = await setupContract(); const { value: arrayBoolean } = await contract.functions .take_array_boolean([true, false, false]) @@ -470,7 +486,7 @@ describe('Contract', () => { }); it('calls enum functions', async () => { - const contract = await setup(); + const contract = await setupContract(); const { value: enumB256ReturnValue } = await contract.functions .take_b256_enum({ diff --git a/packages/contract/src/__test__/test-utils.ts b/packages/contract/src/__test__/test-utils.ts index f577d6fd8a9..fcd8c8217fc 100644 --- a/packages/contract/src/__test__/test-utils.ts +++ b/packages/contract/src/__test__/test-utils.ts @@ -9,8 +9,8 @@ import type Contract from '../contracts/contract'; import ContractFactory from '../contracts/contract-factory'; let contractInstance: Contract; -const deployContract = async (factory: ContractFactory) => { - if (contractInstance) return contractInstance; +const deployContract = async (factory: ContractFactory, useCache: boolean = true) => { + if (contractInstance && useCache) return contractInstance; contractInstance = await factory.deployContract(); return contractInstance; }; @@ -26,16 +26,24 @@ const createWallet = async () => { return walletInstance; }; -export const setup = async ({ - contractBytecode, - abi, -}: { +export type SetupConfig = { contractBytecode: BytesLike; abi: JsonAbi | Interface; -}) => { + cache?: boolean; +}; + +export const setup = async ({ contractBytecode, abi, cache }: SetupConfig) => { // Create wallet const wallet = await createWallet(); const factory = new ContractFactory(contractBytecode, abi, wallet); - const contract = await deployContract(factory); + const contract = await deployContract(factory, cache); return contract; }; + +export const createSetupConfig = + (defaultConfig: SetupConfig) => async (config?: Partial) => + setup({ + contractBytecode: defaultConfig.contractBytecode, + abi: defaultConfig.abi, + ...config, + }); From cd6ad1b3533156e4d1f9125855e3a81cf4685e6b Mon Sep 17 00:00:00 2001 From: Luiz Estacio Date: Wed, 31 Aug 2022 17:20:12 -0300 Subject: [PATCH 10/17] feat: remove byteCode and fix contract to latest sway version --- packages/contract/scripts/build-forc-projects.sh | 2 +- packages/contract/src/contracts/contract-factory.ts | 1 + packages/contract/src/contracts/multicall/src/buf.sw | 4 ++-- .../contract/src/contracts/multicall/src/main.sw | 10 ++++++---- packages/providers/src/operations.graphql | 1 - packages/providers/src/provider.ts | 12 ++---------- .../src/transaction-request/transaction-request.ts | 8 +------- 7 files changed, 13 insertions(+), 25 deletions(-) diff --git a/packages/contract/scripts/build-forc-projects.sh b/packages/contract/scripts/build-forc-projects.sh index e73ef2ee589..eec1e5304cd 100755 --- a/packages/contract/scripts/build-forc-projects.sh +++ b/packages/contract/scripts/build-forc-projects.sh @@ -2,7 +2,7 @@ set -euo pipefail -# scripts/build-multicall.sh +scripts/build-multicall.sh pnpm forc build -p src/__test__/storage-test-contract pnpm forc build -p src/__test__/call-test-contract pnpm forc build -p src/__test__/token-test-contract/token_abi diff --git a/packages/contract/src/contracts/contract-factory.ts b/packages/contract/src/contracts/contract-factory.ts index 28f16231b5d..baee868969e 100644 --- a/packages/contract/src/contracts/contract-factory.ts +++ b/packages/contract/src/contracts/contract-factory.ts @@ -85,6 +85,7 @@ export default class ContractFactory { }); request.addContractCreatedOutput(contractId, stateRoot); await this.wallet.fund(request); + const response = await this.wallet.sendTransaction(request); await response.wait(); diff --git a/packages/contract/src/contracts/multicall/src/buf.sw b/packages/contract/src/contracts/multicall/src/buf.sw index 0084822a0df..10f83f1d288 100644 --- a/packages/contract/src/contracts/multicall/src/buf.sw +++ b/packages/contract/src/contracts/multicall/src/buf.sw @@ -43,7 +43,7 @@ impl Buffer { } /// Copies and appends `buf` to the `Buffer`. - pub fn extend_from_buf(mut self, buf: Self) -> u64 { + pub fn extend_from_buf(ref mut self, buf: Self) -> u64 { if (buf.len == 0) { return self.len; } @@ -60,7 +60,7 @@ impl Buffer { old_len } - pub fn extend_from_ptr(mut self, ptr: u64, len: u64) -> u64 { + pub fn extend_from_ptr(ref mut self, ptr: u64, len: u64) -> u64 { if (len == 0) { return self.len; } diff --git a/packages/contract/src/contracts/multicall/src/main.sw b/packages/contract/src/contracts/multicall/src/main.sw index 9311ccb0555..5529924ed75 100644 --- a/packages/contract/src/contracts/multicall/src/main.sw +++ b/packages/contract/src/contracts/multicall/src/main.sw @@ -10,6 +10,7 @@ use std::mem::*; use std::tx::tx_script_data; use std::option::*; use std::revert::*; +use std::logging::log; use buf::*; use contract_call::*; @@ -45,7 +46,7 @@ fn get_var_data() -> Buffer { ~Buffer::from_ptr(ptr, len) } -fn main(script_data: ScriptData) -> ScriptReturn { +fn main() -> ScriptReturn { // TODO: Remove this line when the bug is fixed: https://github.com/FuelLabs/sway/issues/1585 asm(r1: 0x0000000000000000000000000000000000000000000000000000000000000000) { }; @@ -56,13 +57,14 @@ fn main(script_data: ScriptData) -> ScriptReturn { // which contains reference type call arguments' data let script_data = tx_script_data::(); let var_data = get_var_data(); + log(script_data); + log(var_data); - let mut call_returns: [Option; - 5] = null_of::<[Option; - 5]>(); + let mut call_returns: [Option; 5] = null_of::<[Option; 5]>(); let mut ret_data = ~Buffer::new(); let mut i = 0; let calls_len = size_of_val(script_data.calls) / size_of::>(); + while i < calls_len { match script_data.calls[i] { Option::Some(call) => { diff --git a/packages/providers/src/operations.graphql b/packages/providers/src/operations.graphql index 736517d13f8..c621f907f58 100644 --- a/packages/providers/src/operations.graphql +++ b/packages/providers/src/operations.graphql @@ -69,7 +69,6 @@ fragment chainInfoFragment on ChainInfo { peerCount consensusParameters { gasPriceFactor - gasPerByte maxGasPerTx maxGasPerTx maxScriptLength diff --git a/packages/providers/src/provider.ts b/packages/providers/src/provider.ts index 0ebc280d8f7..20fefbbdc62 100644 --- a/packages/providers/src/provider.ts +++ b/packages/providers/src/provider.ts @@ -10,7 +10,6 @@ import type { BigNumberish } from '@fuel-ts/math'; import { max, multiply } from '@fuel-ts/math'; import type { Transaction } from '@fuel-ts/transactions'; import { - GAS_PER_BYTE, GAS_PRICE_FACTOR, MAX_GAS_PER_TX, ReceiptType, @@ -70,7 +69,6 @@ export type ChainInfo = { peerCount: number; consensusParameters: { gasPriceFactor: bigint; - gasPerByte: bigint; maxGasPerTx: bigint; maxScriptLength: bigint; }; @@ -94,7 +92,6 @@ export type NodeInfo = { export type TransactionCost = { minGasPrice: bigint; gasPrice: bigint; - byteSize: bigint; gasUsed: bigint; fee: bigint; }; @@ -126,7 +123,6 @@ const processGqlChain = (chain: GqlChainInfoFragmentFragment): ChainInfo => ({ peerCount: chain.peerCount, consensusParameters: { gasPriceFactor: BigInt(chain.consensusParameters.gasPriceFactor), - gasPerByte: BigInt(chain.consensusParameters.gasPerByte), maxGasPerTx: BigInt(chain.consensusParameters.maxGasPerTx), maxScriptLength: BigInt(chain.consensusParameters.maxScriptLength), }, @@ -164,7 +160,7 @@ export type CursorPaginationArgs = { export type BuildPredicateOptions = { fundTransaction?: boolean; -} & Pick; +} & Pick; /** * Provider Call transaction params @@ -307,17 +303,13 @@ export default class Provider { // Execute dryRun not validated transaction to query gasUsed const { receipts } = await this.call(transactionRequest); const gasUsed = multiply(getGasUsedFromReceipts(receipts), margin); - const byteSize = transactionRequest.chargeableByteSize(); const gasFee = calculatePriceWithFactor(gasUsed, gasPrice, GAS_PRICE_FACTOR); - const gasBytePrice = multiply(GAS_PER_BYTE, gasPrice); - const byteFee = calculatePriceWithFactor(byteSize, gasBytePrice, GAS_PRICE_FACTOR); return { minGasPrice, gasPrice, gasUsed, - byteSize, - fee: byteFee + gasFee, + fee: gasFee, }; } diff --git a/packages/providers/src/transaction-request/transaction-request.ts b/packages/providers/src/transaction-request/transaction-request.ts index 0247b558728..cac7e4a2996 100644 --- a/packages/providers/src/transaction-request/transaction-request.ts +++ b/packages/providers/src/transaction-request/transaction-request.ts @@ -329,15 +329,9 @@ abstract class BaseTransactionRequest implements BaseTransactionRequestLike { */ calculateFee(): CoinQuantity { const gasFee = calculatePriceWithFactor(this.gasLimit, this.gasPrice, GAS_PRICE_FACTOR); - const gasPerBytePrice = multiply(GAS_PER_BYTE, this.gasPrice); - const byteFee = calculatePriceWithFactor( - this.chargeableByteSize(), - gasPerBytePrice, - GAS_PRICE_FACTOR - ); return { assetId: NativeAssetId, - amount: gasFee + byteFee || 1n, + amount: gasFee || 1n, }; } } From 12b595f74076c6c5a248cae1b4929433b7972363 Mon Sep 17 00:00:00 2001 From: Luiz Estacio Date: Wed, 31 Aug 2022 20:57:15 -0300 Subject: [PATCH 11/17] feat: update static bin and tests --- .../contract/src/__test__/contract.test.ts | 20 +- .../src/contracts/multicall/Forc.toml | 1 + .../src/contracts/multicall/src/main.sw | 14 +- .../multicall/static-out/multicall-abi.json | 2 +- .../multicall/static-out/multicall-bin-hash | 2 +- .../multicall/static-out/multicall-bin.ts | 2 +- .../static-out/multicall-flat-abi.json | 237 ++++++++++++++++++ .../multicall/static-out/multicall.bin | Bin 3520 -> 3428 bytes packages/forc-bin/package.json | 2 +- packages/providers/src/provider.test.ts | 1 - 10 files changed, 254 insertions(+), 27 deletions(-) create mode 100644 packages/contract/src/contracts/multicall/static-out/multicall-flat-abi.json diff --git a/packages/contract/src/__test__/contract.test.ts b/packages/contract/src/__test__/contract.test.ts index 6013dc5c707..49826d72c94 100644 --- a/packages/contract/src/__test__/contract.test.ts +++ b/packages/contract/src/__test__/contract.test.ts @@ -27,6 +27,8 @@ const jsonFragment = { outputs: [], }; +const txPointer = '0x00000000000000000000000000000000'; + const complexFragment = { inputs: [ { @@ -125,8 +127,8 @@ describe('Contract', () => { .addContracts([otherContract.id]); expect(scope.transactionRequest.getContractInputs()).toEqual([ - { contractId: contract.id.toB256(), type: 1 }, - { contractId: otherContract.id.toB256(), type: 1 }, + { contractId: contract.id.toB256(), type: 1, txPointer }, + { contractId: otherContract.id.toB256(), type: 1, txPointer }, ]); expect(scope.transactionRequest.getContractOutputs()).toEqual([ @@ -152,8 +154,8 @@ describe('Contract', () => { .addContracts([otherContract.id]); expect(scope.transactionRequest.getContractInputs()).toEqual([ - { contractId: contract.id.toB256(), type: 1 }, - { contractId: otherContract.id.toB256(), type: 1 }, + { contractId: contract.id.toB256(), type: 1, txPointer }, + { contractId: otherContract.id.toB256(), type: 1, txPointer }, ]); expect(scope.transactionRequest.getContractOutputs()).toEqual([ @@ -194,15 +196,15 @@ describe('Contract', () => { it('adds multiple contracts on multicalls', async () => { const contract = await setupContract(); - const otherContract = await setupContract({ cache: true }); + const otherContract = await setupContract({ cache: false }); const scope = contract .multiCall([contract.functions.foo(1336)]) .addContracts([otherContract.id]); expect(scope.transactionRequest.getContractInputs()).toEqual([ - { contractId: contract.id.toB256(), type: 1 }, - { contractId: otherContract.id.toB256(), type: 1 }, + { contractId: contract.id.toB256(), type: 1, txPointer }, + { contractId: otherContract.id.toB256(), type: 1, txPointer }, ]); expect(scope.transactionRequest.getContractOutputs()).toEqual([ @@ -385,7 +387,7 @@ describe('Contract', () => { const transactionCost = await invocationScope.getTransactionCost(); expect(transactionCost.gasPrice).toBe(1n); - expect(transactionCost.fee).toBeGreaterThanOrEqual(2n); + expect(transactionCost.fee).toBeGreaterThanOrEqual(1n); expect(transactionCost.gasUsed).toBeGreaterThan(1000n); // Test that gasUsed is correctly calculated @@ -418,7 +420,7 @@ describe('Contract', () => { }); expect(transactionCost.gasPrice).toBe(2n); - expect(transactionCost.fee).toBeGreaterThanOrEqual(4n); + expect(transactionCost.fee).toBeGreaterThanOrEqual(2n); expect(transactionCost.gasUsed).toBeGreaterThan(1000n); // Test that gasUsed is correctly calculated diff --git a/packages/contract/src/contracts/multicall/Forc.toml b/packages/contract/src/contracts/multicall/Forc.toml index 88b54e64dc9..ff0555ca392 100644 --- a/packages/contract/src/contracts/multicall/Forc.toml +++ b/packages/contract/src/contracts/multicall/Forc.toml @@ -3,3 +3,4 @@ name = "multicall" license = "Apache-2.0" [dependencies] +std = { path = "/Users/luizstacio/fuels/sway/sway-lib-std" } \ No newline at end of file diff --git a/packages/contract/src/contracts/multicall/src/main.sw b/packages/contract/src/contracts/multicall/src/main.sw index 5529924ed75..d11d5cebeb3 100644 --- a/packages/contract/src/contracts/multicall/src/main.sw +++ b/packages/contract/src/contracts/multicall/src/main.sw @@ -46,20 +46,8 @@ fn get_var_data() -> Buffer { ~Buffer::from_ptr(ptr, len) } -fn main() -> ScriptReturn { - // TODO: Remove this line when the bug is fixed: https://github.com/FuelLabs/sway/issues/1585 - asm(r1: 0x0000000000000000000000000000000000000000000000000000000000000000) { - }; - - // Our script data is a fixed-size struct followed by a variable-length array of bytes. - // ScriptData can represent only this fixed-size part, - // and we will use a RawPointer to access the variable-length part, - // which contains reference type call arguments' data - let script_data = tx_script_data::(); +fn main(script_data: ScriptData) -> ScriptReturn { let var_data = get_var_data(); - log(script_data); - log(var_data); - let mut call_returns: [Option; 5] = null_of::<[Option; 5]>(); let mut ret_data = ~Buffer::new(); let mut i = 0; diff --git a/packages/contract/src/contracts/multicall/static-out/multicall-abi.json b/packages/contract/src/contracts/multicall/static-out/multicall-abi.json index 10aa476507d..d8d6d045853 100644 --- a/packages/contract/src/contracts/multicall/static-out/multicall-abi.json +++ b/packages/contract/src/contracts/multicall/static-out/multicall-abi.json @@ -441,4 +441,4 @@ } ] } -] +] \ No newline at end of file diff --git a/packages/contract/src/contracts/multicall/static-out/multicall-bin-hash b/packages/contract/src/contracts/multicall/static-out/multicall-bin-hash index c2e5963cc33..5410d6aae1f 100644 --- a/packages/contract/src/contracts/multicall/static-out/multicall-bin-hash +++ b/packages/contract/src/contracts/multicall/static-out/multicall-bin-hash @@ -1 +1 @@ -0x71e7b6dc3265b49590c6cad582b1afd367d348b8c5105a300d200a1c87aa7efe \ No newline at end of file +0x01bddf8b3b3c0099386c1849c19c3346dff57e82a792582d4e4b9f9619e699ba \ No newline at end of file diff --git a/packages/contract/src/contracts/multicall/static-out/multicall-bin.ts b/packages/contract/src/contracts/multicall/static-out/multicall-bin.ts index 5ddd5392b5b..5157c199af8 100644 --- a/packages/contract/src/contracts/multicall/static-out/multicall-bin.ts +++ b/packages/contract/src/contracts/multicall/static-out/multicall-bin.ts @@ -1 +1 @@ -export default '0x90000004470000000000000000000d485dfcc00110fff3001a5c5000910008485d43f00e104103005d43f0045d47f0055d451000104514005d43f0067340001190000012900000135d4510005041746850417468604112d05d47f0045d43f0055d41000010450440504174105f5d1082504174105d4570825d43f00710450440504174285f5d10855d43f0085d4500005d43f00720451400504173605f5d106c504174285d497085504173605d41706c1a445000910000105f4520005f4500015041783850417838604110105d47f00926440000504470015041724050417240604110a05d43f00a26400000504070011a445000910000105f4500005d43f00a5f450001504174585041745860411010504173305d43f00a5f5d006650417468504100005d47f0075d43f00b12451400504172e05f5d105c504173305d457066504172e05d41705c1641140073400055900000645041746850450000504173305d4170665541009010411400504570685045706860450090504170685d4500005d43f00c13411400734000f690000323504972401a445000910000a050411000604120a05041773850417738604110a05d43f00a26400000504070011a445000910000105f4500005d43f00a5f45000150417178504171786041101050597178505577385d43f006134100007340007d900000815d43f00a364000005d43f00a900000825d43f00a504177385d53f0095d43f00a13414400734000889000008a5d416001900000b65d43f00a5d456001504173e85f5d107d5d41600110454400504173a85f5d10755d4d60005d496001504173a85d4570751541148073400099900000aa2644000050447001504173885f5d10715d43f00a15412400734000a1900000a6504173885d417071284134805d43f00a900000a75d43f00a504173885d4d7071900000aa5f593000504173a85d4170755f5900015d456000504173e85d41707d10410440284155005d43f00a504173e85d41707d50557178505174585d4540015d43f00a13411400734000bd900000bf5d415001900000ee5d43f00a5d455001504173f05f5d107e5d4550015d41400110450440504173b05f5d10765d4d50005d495001504173b05d45707615411480734000cf900000e02644000050447001504173905f5d10725d43f00a15412400734000d7900000dc504173905d417072284134805d43f00a900000dd5d43f00a504173905d4d7072900000e05f553000504173b05d4170765f5500015d4940005d455000504173f05d41707e104504405d414001284524005d43f00a504173f05d41707e504171785d450000504171785d41000125450000504577385d43f0092545000050417068504500085041718850417188604110885041718850450028504170f8504170f860411018504170f85d4500005d43f00a134114007340010690000112504170f85d450002504177d85f5d10fb504177d85d4970fb1a445000910000185d43f00a5f4500005f4520029000014f504170f85d4500005d43f00c134114007340011890000134504170f8504100085d450000504173c85f5d1079504170f8504100085d450001504173585f5d106b504178385d450000504173c85d41707910450440504173585d41706b1a485000910000105f4910005f4900011a445000910000185d43f00c5f45000050411008604120109000014f504170f8504100085d450000504173d05f5d107a504170f8504100085d450001504173705f5d106e504178385d450000504173d05d41707a10450440504173705d41706e1a485000910000105f4910005f4900011a445000910000185d43f00c5f4500005041100860412010504172e8504172e8604110185041718850550000504171885d510004504572e850417188504d0040504170005041700060411018504170005d4500005d43f00a134114007340016290000169504170005d450002504177e05f5d10fc504177e05d4570fc9000017e504170005d4500005d43f00c134114007340016f9000017750417000504100085d450000504174185f5d1083504174185d4570839000017e50417000504100085d450000504174305f5d1086504174305d457086504173005f5d1060504173005d4970601a4450009100003050411000604150205f4540045f45200550417210504172106041103050453000504170185041701860411010504170185d4500005d43f00c13411400734001959000019c504170185d450001504171285f5d1025504171285d457025900001a5504170185d4500005d43f00a13411400734001a2900001a45d47f00a900001a55d47f00a504171305f5d102650453010504170285041702860411028504170285d4500005d43f00c13411400734001b1900001b8504170285045000850417338504173386041102050497338900001cb504170285d4500005d43f00a13411400734001be900001c51a485000910000205d47f00e104513005041200060411020900001cb1a485000910000205d47f00e10451300504120006041102050417138504171386041202050453038504170505041705060411010504170505d4500005d43f00c13411400734001d8900001df504170505d450001504173205f5d1064504173205d457064900001e8504170505d4500005d43f00a13411400734001e5900001e71a44a000900001e81a44a000504173285f5d1065504d7210504171305d49702650457138504173285d4170652d4d24501a44e000504170605f5d100c504170605d45700c5d43f00a13411400734001fa900002051a44d000504178085f5d1101504178085d4971011a445000910000185d43f00a5f4500005f4520029000021a504170605d45700c504173685f5d106d1a44d000504174385f5d1087504174385d457087504173685d41706d1a485000910000105f4910005f4900011a445000910000185d43f00c5f450000504110086041201050417440504174406041101850457440504171105041711060411018504171105d4500005d43f00a134114007340022790000233504171105d450002504178305f5d1106504178305d4971061a445000910000185d43f00a5f4500005f452002900002f4504171105d4500005d43f00c13411400734002399000029750417110504100085d450000504174085f5d108150417110504100085d450001504173785f5d106f504174085d457081504173785d41706f1a485000910000105f4910005f49000150417158504171586041201050557458505171585d4540015d43f00a1341140073400255900002575d455001900002865d43f00a5d455001504173f85f5d107f5d4550015d41400110450440504173b85f5d10775d4d50005d495001504173b85d4570771541148073400267900002782644000050447001504173985f5d10735d43f00a154124007340026f90000274504173985d417073284134805d43f00a900002755d43f00a504173985d4d7073900002785f553000504173b85d4170775f5500015d4940005d455000504173f85d41707f104504405d414001284524005d43f00a504173f85d45707f504173d85f5d107b504173d85d45707b504173785d41706f1a485000910000105f4910005f4900011a445000910000185d43f00c5f4500005041100860412010900002f450417110504100085d450000504174205f5d108450417110504100085d450001504173805f5d1070504174205d457084504173805d4170701a485000910000105f4910005f49000150417168504171686041201050557458505171685d4540015d43f00a13411400734002b3900002b55d455001900002e45d43f00a5d455001504174005f5d10805d4550015d41400110450440504173c05f5d10785d4d50005d495001504173c05d45707815411480734002c5900002d62644000050447001504173a05f5d10745d43f00a15412400734002cd900002d2504173a05d417074284134805d43f00a900002d35d43f00a504173a05d4d7074900002d65f553000504173c05d4170785f5500015d4940005d455000504174005d417080104504405d414001284524005d43f00a504174005d457080504173e05f5d107c504173e05d45707c504173805d4170701a485000910000105f4910005f4900011a445000910000185d43f00c5f4500005041100860412010504173085041730860411018504973081a445000910000205d43f00c5f4500005041100860412018504177e8504177e86041102050457240504173305d41706655490020104914805d43f006134100007340030a9000030e5d43f00a364000005d43f00a9000030f5d43f00a504577e85d43f00673400313900003205d43f00613410000734003179000031b5d43f00a364000005d43f00a9000031c5d43f00a5d43f00d284914005d43f00a900003215f4910005d43f00a9000034b504178101a445000910000205d43f00a5f450000504178106041102050457240504173305d41706655490020104914805d43f0061341000073400333900003375d43f00a364000005d43f00a900003385d43f00a504578105d43f0067340033c900003495d43f0061341000073400340900003445d43f00a364000005d43f00a900003455d43f00a5d43f00d284914005d43f00a9000034a5f4910005d43f00a50417330504173305d4570665d43f00c104104405f5d00669000004e000000000000000000000000000000000000000000000000000000000000000000000000000028700000000000002828000000000000000100000000000002d0000000000000283000000000000000a000000000000000000000000000000090000000000000000100000000000000200000000000000d48'; +export default '0x90000004470000000000000000000d0c5dfcc00110fff3001a5c5000910005b861440006724002d0164114005b40100d360000006158000c61440001504175305f5d10a6504175305d4570a6504171385f5d1027504171385d417027134100007340001a9000001f1a445000910000085d43f0005f4500009000002b504171385d4170271341004073400024900000291a445000910000085d43f0015f4500009000002b360000001a44000050417528504175286041100850457528504170085041700860411008504170085d4100001341000073400037900000396144000c9000003b360000001a440000504174305f5d1086504174305d4570865d43f00210450440504174485f5d108961440001504175405f5d10a8504175405d4570a8504171405f5d1028504171405d417028134100007340004f900000541a445000910000085d43f0005f45000090000060504171405d41702813410040734000599000005e1a445000910000085d43f0015f45000090000060360000001a44000050417538504175386041100850457538504170005041700060411008504170005d410000134100007340006c9000006e6144000690000078504170005d410000134100407340007390000076360000001a44000090000078360000001a4400005d43f00220451400504173805f5d1070504174485d497089504173805d4170701a445000910000105f4520005f450001504175a8504175a8604110105d47f00326440000504470015041726050417260604110a026000000504070011a445000910000105f4500005f440001504174785041747860411010504173505f5c006a504160005d47f0025d43f00412451400504173005f5d1060504173505d45706a504173005d41706016411400734000a5900000b250496000504173505d41706a5545009010452440504170785041707860411090504170785d410000134100407340012d9000032d504972601a445000910000a050411000604120a05041748850417488604110a026000000504070011a445000910000105f4500005f4400015041719850417198604110105051719850557488504174885d454001504174085f5d10815d4540015d43f00310450440504173c85f5d10795d4140005d4d4001504573c85d457079154914c0734800d5900000e52644000050487001504573a85f5d207515453000734400dc900000e1504573a85d457075284504c01a400000900000e21a400000504173a85d417075900000e55f510000504173c85d4170795f5100015d454000504174085d417081104504405d43f00328455400504174085d41708150557198505174785d41400113410000734000f7900000f95d415001900001255d455001504174105f5d10825d4550015d41400110450440504173d05f5d107a5d4150005d4d5001504573d05d45707a154914c073480108900001182644000050487001504573b05f5d2076154530007344010f90000114504573b05d457076284504c01a400000900001151a400000504173b05d417076900001185f550000504173d05d41707a5f5500015d4940005d455000504174105d417082104504405d41400128452400504174105d417082504171985d450000504171985d41000125450000504574885d43f003254500005041707850450008504171a8504171a860411088504171a850450028504171085041710860411018504171085d410000134100007340013c90000148504171085d450002504175485f5d10a9504175485d4970a91a445000910000185d43f0005f4500005f45200290000184504171085d410000134100407340014d9000016950417108504100085d450000504173e85f5d107d50417108504100085d450001504173785f5d106f504175a85d450000504173e85d41707d10450440504173785d41706f1a485000910000105f4910005f4900011a445000910000185d43f0015f45000050411008604120109000018450417108504100085d450000504173f05f5d107e50417108504100085d450001504173905f5d1072504175a85d450000504173f05d41707e10450440504173905d4170721a485000910000105f4910005f4900011a445000910000185d43f0015f4500005041100860412010504173085041730860411018504171a850550000504171a85d51000450457308504171a8504d0040504170105041701060411018504170105d41000013410000734001969000019d504170105d450002504175505f5d10aa504175505d4570aa900001b1504170105d41000013410040734001a2900001aa50417010504100085d450000504174385f5d1087504174385d457087900001b150417010504100085d450000504174505f5d108a504174505d45708a504173205f5d1064504173205d4970641a4450009100003050411000604150205f4540045f45200550417230504172306041103050453000504170285041702860411010504170285d41000013410040734001c7900001ce504170285d450001504171485f5d1029504171485d457029900001d6504170285d41000013410000734001d3900001d51a440000900001d61a440000504171505f5d102a50453010504170385041703860411028504170385d41000013410040734001e1900001e8504170385045000850417358504173586041102050497358900001fa504170385d41000013410000734001ed900001f41a485000910000205d47f00a104513005041200060411020900001fa1a485000910000205d47f00a10451300504120006041102050417158504171586041202050453038504170605041706060411010504170605d41000013410040734002069000020d504170605d450001504173405f5d1068504173405d45706890000215504170605d4100001341000073400212900002141a44a000900002151a44a000504173485f5d1069504d7230504171505d49702a50457158504173485d4170692d4d24501a44e000504170705f5d100e504170705d41700e1341000073400226900002311a44d000504175785f5d10af504175785d4570af1a485000910000185d43f0005f4900005f49100290000246504170705d45700e504173885f5d10711a44d000504174585f5d108b504174585d49708b504173885d4170711a445000910000105f4520005f4500011a485000910000185d43f0015f490000504120086041101050417460504174606041201850457460504171205041712060411018504171205d41000013410000734002529000025e504171205d450002504175a05f5d10b4504175a05d4970b41a445000910000185d43f0005f4500005f45200290000316504171205d4100001341004073400263900002bd50417120504100085d450000504174285f5d108550417120504100085d450001504173985f5d1073504174285d497085504173985d4170731a445000910000105f4520005f45000150417178504171786041101050557478505171785d414001134100007340027e900002805d455001900002ac5d455001504174185f5d10835d4550015d41400110450440504173d85f5d107b5d4150005d4d5001504573d85d45707b154914c07348028f9000029f2644000050487001504573b85f5d207715453000734402969000029b504573b85d457077284504c01a4000009000029c1a400000504173b85d4170779000029f5f550000504173d85d41707b5f5500015d4940005d455000504174185d417083104504405d41400128452400504174185d457083504173f85f5d107f504173f85d45707f504173985d4170731a485000910000105f4910005f4900011a445000910000185d43f0015f45000050411008604120109000031650417120504100085d450000504174405f5d108850417120504100085d450001504173a05f5d1074504174405d497088504173a05d4170741a445000910000105f4520005f45000150417188504171886041101050557478505171885d41400113410000734002d8900002da5d455001900003065d455001504174205f5d10845d4550015d41400110450440504173e05f5d107c5d4150005d4d5001504573e05d45707c154914c0734802e9900002f92644000050487001504573c05f5d207815453000734402f0900002f5504573c05d457078284504c01a400000900002f61a400000504173c05d417078900002f95f550000504173e05d41707c5f5500015d4940005d455000504174205d417084104504405d41400128452400504174205d457084504174005f5d1080504174005d457080504173a05d4170741a485000910000105f4910005f4900011a445000910000185d43f0015f4500005041100860412010504173285041732860411018504973281a445000910000205d43f0015f450000504110086041201850417558504175586041102050457260504173505d41706a5549002010491480504575585d43f009284914001a4000009000033d504175801a445000910000205d43f0005f450000504175806041102050457260504173505d41706a5549002010491480504575805d43f009284914001a40000050417350504173505d41706a104014005f5d006a9000009e0000000000000000000000000000000100000000000002d000000000000000a00000000000000090000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000d34'; diff --git a/packages/contract/src/contracts/multicall/static-out/multicall-flat-abi.json b/packages/contract/src/contracts/multicall/static-out/multicall-flat-abi.json new file mode 100644 index 00000000000..e2fe23fc569 --- /dev/null +++ b/packages/contract/src/contracts/multicall/static-out/multicall-flat-abi.json @@ -0,0 +1,237 @@ +{ + "types": [ + { + "typeId": 0, + "type": "()", + "components": [], + "typeParameters": null + }, + { + "typeId": 1, + "type": "(_, _)", + "components": [ + { + "name": "__tuple_element", + "type": 13, + "typeArguments": null + }, + { + "name": "__tuple_element", + "type": 13, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 2, + "type": "[_; 5]", + "components": [ + { + "name": "__array_element", + "type": 6, + "typeArguments": [ + { + "name": "", + "type": 10, + "typeArguments": null + } + ] + } + ], + "typeParameters": null + }, + { + "typeId": 3, + "type": "[_; 5]", + "components": [ + { + "name": "__array_element", + "type": 6, + "typeArguments": [ + { + "name": "", + "type": 5, + "typeArguments": null + } + ] + } + ], + "typeParameters": null + }, + { + "typeId": 4, + "type": "b256", + "components": null, + "typeParameters": null + }, + { + "typeId": 5, + "type": "enum CallValue", + "components": [ + { + "name": "Value", + "type": 13, + "typeArguments": null + }, + { + "name": "Data", + "type": 1, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 6, + "type": "enum Option", + "components": [ + { + "name": "None", + "type": 0, + "typeArguments": null + }, + { + "name": "Some", + "type": 7, + "typeArguments": null + } + ], + "typeParameters": [ + 7 + ] + }, + { + "typeId": 7, + "type": "generic T", + "components": null, + "typeParameters": null + }, + { + "typeId": 8, + "type": "struct CallParameters", + "components": [ + { + "name": "amount", + "type": 6, + "typeArguments": [ + { + "name": "", + "type": 13, + "typeArguments": null + } + ] + }, + { + "name": "asset_id", + "type": 6, + "typeArguments": [ + { + "name": "", + "type": 9, + "typeArguments": null + } + ] + }, + { + "name": "gas", + "type": 6, + "typeArguments": [ + { + "name": "", + "type": 13, + "typeArguments": null + } + ] + } + ], + "typeParameters": null + }, + { + "typeId": 9, + "type": "struct ContractId", + "components": [ + { + "name": "value", + "type": 4, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 10, + "type": "struct MulticallCall", + "components": [ + { + "name": "contract_id", + "type": 9, + "typeArguments": null + }, + { + "name": "fn_selector", + "type": 13, + "typeArguments": null + }, + { + "name": "fn_arg", + "type": 5, + "typeArguments": null + }, + { + "name": "parameters", + "type": 8, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 11, + "type": "struct ScriptData", + "components": [ + { + "name": "calls", + "type": 2, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 12, + "type": "struct ScriptReturn", + "components": [ + { + "name": "call_returns", + "type": 3, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 13, + "type": "u64", + "components": null, + "typeParameters": null + } + ], + "functions": [ + { + "inputs": [ + { + "name": "script_data", + "type": 11, + "typeArguments": null + } + ], + "name": "main", + "output": { + "name": "", + "type": 12, + "typeArguments": null + } + } + ] +} \ No newline at end of file diff --git a/packages/contract/src/contracts/multicall/static-out/multicall.bin b/packages/contract/src/contracts/multicall/static-out/multicall.bin index 1fe4c222d1528b5a75d4106805c7f0c578296058..55b6b58e08b86a111442eac9254c95e609f7be51 100644 GIT binary patch literal 3428 zcma);U1%It6vyvO(h{YqL%S)id(OG% zoc}rJ-m`6`dUvbr*S{(JYsqr{{#ljw2I_6KVR3&|ZJhM%)sRv6{v8VdNXV+BSR|?)EIXw@(L3lfJ zdRC?*y%1CqiT47r*pA=p zu^)kd$zbwWFW|>R2ilZ9zM3AG%Etcl*xi$hHN(`%=?SJ6(c72P%P=)MF|~&AHEb}k zj=&iygGuEuy@IV*r5?~}(J?ad6T_RzY>GTv3r5#3U^AWpM8FW}z^cdzwqm%LXa_>*9pY`~x2PCWuIvN~s#s_TA8h%1?vv)B*nd)48f(oop3 ziKBN*8iyhdY{dcjMIM7AYDj;9<6~m~Jg7A!-T?mLabL9^f6xQ3U>4hLp&jhjuD0sg z71SmhCZ74A;*dWVn#{`g|1me`sM(y3d5raVdM5NeFeiP)dPdg7-;?%Ad;{LGu;Qt3 z6dgal0ght>wZc+7qHYrZ4?1TfY>{j@P|}fRo@}IB|P+7Wxsc+tlLq0c=)25)u+cxCv%x*HM&TV2 zUQppJ(=o=kv2!ZNBiHdXyd!dtG99pIlAF+ci&hobq==wDm!ZFoLy(PB`!Km`MgWU1R zN%I_0%k1s7-XZ4qMFw`sb3klYgwiWlkbS0QslMd&BY4QgUY65D=Ey~QWSBD-vokrl z*n9)I*o4L|`vXF$Yoxy&XG`ma5ChTXK)C3dQ$TgDt(IHD*rD;f~tR>GOVs zop=`gW_mW6VEraNGJ$_+Jc|!x=H8ikm$PYc5Ao?r?^Cm+As_iF^7gQ9y7D0_3hnf} z{Q@!U)4a6b=ka@;nCJ0({oe0N&$gTm`oMk}8(#=7*W+dEyq@DpE#~0G#8t*NvUmMjv%%*6+wbyLETVt3GaKyp%xqXB=A&}n%!U>AC%R@s5#G73*-*sZIWYf0T(1db zFLX}lVBPO&n)_UyrN3vp@+>t>$g@YDk;U`)NbZqmIX9cjGd-5gV0#6O-==x)*=X|Y zV)uMko>$?W%;k9%TqjMQf5gU}T%MQ6^R&tH8nR!>^Ah^gxjg@7^1MXM({kSAd6oUi zt~}Gn(fO`CyVzsyC5pIagtCX49IP|X=$GZw_oWt>P43*T`Nmyp@h-H|H_w;3Jsq>M;M8K2ZPu VS?ShZHtcyrQC-*1O||+T`v*UEbUgq7 literal 3520 zcma)f10k_I^ErBSUrr`)?9=@i>}}ygBiL}qEjTeg$@bQ)=2+NGTA1r zwoO}G7f(tm1sv*q+DXurREdBArqWw~Rr9t?A8 zOGl{@o>9R)r%{!s;*2aH+mFnE?91d>4Zh(eFRMyiwjqoxI4- zzo2ObiBjfk5_9F&LCS8 zU0a=PV&gsdAEIN19M&?^(Cb>q{x)L8mQQ%5DX%e$* z40cpv#NbK#;wG`(63QIjGQF9WIG7z~&`u)%TuhJY=R_KOm*C8ho^4{ffvyuVOmaU3 zc1UJ8iYL55+$T&8rg%RzK51sYV5xFJb!S+77#1IxlN57eb^VChTR`{89(w`U(U`pj zY@9Uq0^X0V*B-OKBu|t_@?6sOnDO_he$N#iSW(eS0X_!Ivd%a4jb<xxk7 zS}}FaMrV#^m)%@HwH+Wn&cwQf?^(~4UJayY(yYM)Z0T6Ke!Yd=cMVQ$YZ+{87mCg8 z@Gi&pbo=dn@DDg+nft_Lp~#D`JFq78p3F47+()J4B1iY_= z*OTurz^|Jc+t}M|xue8oOMPtFb2lD-p}&TH+r~HE15X~43$Mqwo9Oyk_~6p#HZgHG zgf_X@50C!PJU!Q@7k&l*Z9G4#gfA3%$>9O7D0Qf1sTFwdrjhzzDf(dvqs5B@Oh`fnTZztuw_sveh;pF1||QD=`sD7 zd;&dh3m%&Ta$uc}VN#nG*fIR$oC@HDEn+*?8ykD3+r#5xx{gUMVPre}c z2=t=Vz}zn@=s(kQzs!L(WB1D(wwuxYl6;B%t=Ro?3E5EeMfXdR`A;_R^AdiBtM^NC zT4Xd{3_{Ui?w2{_nmzZ+3fP%7?w1w(ID?Lx*nCAOYoTlABvy-_vpA|pEbr3)ul3}; z4Hl4hnF)Ad8=rzT@?K?MHJ0~kPu@Qz*3V4de_73YL!rOjllOVBRxI!H*lwA;Uq{dP zvAoYB+lb};Yxv*d=PZ6UVtN10pLxhUROU_>ocCv#Z!6}n zK9dAnhmSki|9Fo*`R*O^+?E9uAD={~An(z)a9@sfzGsgsYo54|Pj`Kk9O*pq-H*($ ue0R$K1is^*?f!%Mf0_v*ekNn&5)n-<7(8q6Swp)76Z&W5l^rcNP5ui;F28yJ diff --git a/packages/forc-bin/package.json b/packages/forc-bin/package.json index 18086ce4c05..50d73bf7f7b 100644 --- a/packages/forc-bin/package.json +++ b/packages/forc-bin/package.json @@ -1,7 +1,7 @@ { "private": true, "name": "forc-bin", - "version": "0.20.2", + "version": "0.21.0", "description": "", "author": "Fuel Labs (https://fuel.network/)", "typedocMain": "src/index.ts", diff --git a/packages/providers/src/provider.test.ts b/packages/providers/src/provider.test.ts index c0ce6cbcecc..fcbaa1b5612 100644 --- a/packages/providers/src/provider.test.ts +++ b/packages/providers/src/provider.test.ts @@ -131,7 +131,6 @@ describe('Provider', () => { const { consensusParameters } = await provider.getChain(); expect(consensusParameters.gasPriceFactor).toBeGreaterThan(0n); - expect(consensusParameters.gasPerByte).toBeGreaterThan(0n); }); it('can get node info including minGasPrice', async () => { From 186985d0a1787f0d4860d0a0e46c763a69e45665 Mon Sep 17 00:00:00 2001 From: Luiz Estacio Date: Thu, 1 Sep 2022 21:17:21 -0300 Subject: [PATCH 12/17] chore: bump sway version --- packages/forc-bin/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/forc-bin/package.json b/packages/forc-bin/package.json index 50d73bf7f7b..f9f4ec60531 100644 --- a/packages/forc-bin/package.json +++ b/packages/forc-bin/package.json @@ -1,7 +1,7 @@ { "private": true, "name": "forc-bin", - "version": "0.21.0", + "version": "0.22.1", "description": "", "author": "Fuel Labs (https://fuel.network/)", "typedocMain": "src/index.ts", From 1e70fac85a76f1630f75fe576041c335d8d2d15d Mon Sep 17 00:00:00 2001 From: Luiz Estacio Date: Thu, 1 Sep 2022 21:17:45 -0300 Subject: [PATCH 13/17] chore: update static bin for contract call --- .../multicall/static-out/multicall-bin-hash | 2 +- .../multicall/static-out/multicall-bin.ts | 2 +- .../multicall/static-out/multicall.bin | Bin 3428 -> 3372 bytes 3 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/contract/src/contracts/multicall/static-out/multicall-bin-hash b/packages/contract/src/contracts/multicall/static-out/multicall-bin-hash index 5410d6aae1f..4604ddaa268 100644 --- a/packages/contract/src/contracts/multicall/static-out/multicall-bin-hash +++ b/packages/contract/src/contracts/multicall/static-out/multicall-bin-hash @@ -1 +1 @@ -0x01bddf8b3b3c0099386c1849c19c3346dff57e82a792582d4e4b9f9619e699ba \ No newline at end of file +0x705a6f548a3eb8591508092d89cda0803e4a30ad0d43354caa0c6493f2e7b7a9 \ No newline at end of file diff --git a/packages/contract/src/contracts/multicall/static-out/multicall-bin.ts b/packages/contract/src/contracts/multicall/static-out/multicall-bin.ts index 5157c199af8..b642515f2b8 100644 --- a/packages/contract/src/contracts/multicall/static-out/multicall-bin.ts +++ b/packages/contract/src/contracts/multicall/static-out/multicall-bin.ts @@ -1 +1 @@ -export default '0x90000004470000000000000000000d0c5dfcc00110fff3001a5c5000910005b861440006724002d0164114005b40100d360000006158000c61440001504175305f5d10a6504175305d4570a6504171385f5d1027504171385d417027134100007340001a9000001f1a445000910000085d43f0005f4500009000002b504171385d4170271341004073400024900000291a445000910000085d43f0015f4500009000002b360000001a44000050417528504175286041100850457528504170085041700860411008504170085d4100001341000073400037900000396144000c9000003b360000001a440000504174305f5d1086504174305d4570865d43f00210450440504174485f5d108961440001504175405f5d10a8504175405d4570a8504171405f5d1028504171405d417028134100007340004f900000541a445000910000085d43f0005f45000090000060504171405d41702813410040734000599000005e1a445000910000085d43f0015f45000090000060360000001a44000050417538504175386041100850457538504170005041700060411008504170005d410000134100007340006c9000006e6144000690000078504170005d410000134100407340007390000076360000001a44000090000078360000001a4400005d43f00220451400504173805f5d1070504174485d497089504173805d4170701a445000910000105f4520005f450001504175a8504175a8604110105d47f00326440000504470015041726050417260604110a026000000504070011a445000910000105f4500005f440001504174785041747860411010504173505f5c006a504160005d47f0025d43f00412451400504173005f5d1060504173505d45706a504173005d41706016411400734000a5900000b250496000504173505d41706a5545009010452440504170785041707860411090504170785d410000134100407340012d9000032d504972601a445000910000a050411000604120a05041748850417488604110a026000000504070011a445000910000105f4500005f4400015041719850417198604110105051719850557488504174885d454001504174085f5d10815d4540015d43f00310450440504173c85f5d10795d4140005d4d4001504573c85d457079154914c0734800d5900000e52644000050487001504573a85f5d207515453000734400dc900000e1504573a85d457075284504c01a400000900000e21a400000504173a85d417075900000e55f510000504173c85d4170795f5100015d454000504174085d417081104504405d43f00328455400504174085d41708150557198505174785d41400113410000734000f7900000f95d415001900001255d455001504174105f5d10825d4550015d41400110450440504173d05f5d107a5d4150005d4d5001504573d05d45707a154914c073480108900001182644000050487001504573b05f5d2076154530007344010f90000114504573b05d457076284504c01a400000900001151a400000504173b05d417076900001185f550000504173d05d41707a5f5500015d4940005d455000504174105d417082104504405d41400128452400504174105d417082504171985d450000504171985d41000125450000504574885d43f003254500005041707850450008504171a8504171a860411088504171a850450028504171085041710860411018504171085d410000134100007340013c90000148504171085d450002504175485f5d10a9504175485d4970a91a445000910000185d43f0005f4500005f45200290000184504171085d410000134100407340014d9000016950417108504100085d450000504173e85f5d107d50417108504100085d450001504173785f5d106f504175a85d450000504173e85d41707d10450440504173785d41706f1a485000910000105f4910005f4900011a445000910000185d43f0015f45000050411008604120109000018450417108504100085d450000504173f05f5d107e50417108504100085d450001504173905f5d1072504175a85d450000504173f05d41707e10450440504173905d4170721a485000910000105f4910005f4900011a445000910000185d43f0015f4500005041100860412010504173085041730860411018504171a850550000504171a85d51000450457308504171a8504d0040504170105041701060411018504170105d41000013410000734001969000019d504170105d450002504175505f5d10aa504175505d4570aa900001b1504170105d41000013410040734001a2900001aa50417010504100085d450000504174385f5d1087504174385d457087900001b150417010504100085d450000504174505f5d108a504174505d45708a504173205f5d1064504173205d4970641a4450009100003050411000604150205f4540045f45200550417230504172306041103050453000504170285041702860411010504170285d41000013410040734001c7900001ce504170285d450001504171485f5d1029504171485d457029900001d6504170285d41000013410000734001d3900001d51a440000900001d61a440000504171505f5d102a50453010504170385041703860411028504170385d41000013410040734001e1900001e8504170385045000850417358504173586041102050497358900001fa504170385d41000013410000734001ed900001f41a485000910000205d47f00a104513005041200060411020900001fa1a485000910000205d47f00a10451300504120006041102050417158504171586041202050453038504170605041706060411010504170605d41000013410040734002069000020d504170605d450001504173405f5d1068504173405d45706890000215504170605d4100001341000073400212900002141a44a000900002151a44a000504173485f5d1069504d7230504171505d49702a50457158504173485d4170692d4d24501a44e000504170705f5d100e504170705d41700e1341000073400226900002311a44d000504175785f5d10af504175785d4570af1a485000910000185d43f0005f4900005f49100290000246504170705d45700e504173885f5d10711a44d000504174585f5d108b504174585d49708b504173885d4170711a445000910000105f4520005f4500011a485000910000185d43f0015f490000504120086041101050417460504174606041201850457460504171205041712060411018504171205d41000013410000734002529000025e504171205d450002504175a05f5d10b4504175a05d4970b41a445000910000185d43f0005f4500005f45200290000316504171205d4100001341004073400263900002bd50417120504100085d450000504174285f5d108550417120504100085d450001504173985f5d1073504174285d497085504173985d4170731a445000910000105f4520005f45000150417178504171786041101050557478505171785d414001134100007340027e900002805d455001900002ac5d455001504174185f5d10835d4550015d41400110450440504173d85f5d107b5d4150005d4d5001504573d85d45707b154914c07348028f9000029f2644000050487001504573b85f5d207715453000734402969000029b504573b85d457077284504c01a4000009000029c1a400000504173b85d4170779000029f5f550000504173d85d41707b5f5500015d4940005d455000504174185d417083104504405d41400128452400504174185d457083504173f85f5d107f504173f85d45707f504173985d4170731a485000910000105f4910005f4900011a445000910000185d43f0015f45000050411008604120109000031650417120504100085d450000504174405f5d108850417120504100085d450001504173a05f5d1074504174405d497088504173a05d4170741a445000910000105f4520005f45000150417188504171886041101050557478505171885d41400113410000734002d8900002da5d455001900003065d455001504174205f5d10845d4550015d41400110450440504173e05f5d107c5d4150005d4d5001504573e05d45707c154914c0734802e9900002f92644000050487001504573c05f5d207815453000734402f0900002f5504573c05d457078284504c01a400000900002f61a400000504173c05d417078900002f95f550000504173e05d41707c5f5500015d4940005d455000504174205d417084104504405d41400128452400504174205d457084504174005f5d1080504174005d457080504173a05d4170741a485000910000105f4910005f4900011a445000910000185d43f0015f4500005041100860412010504173285041732860411018504973281a445000910000205d43f0015f450000504110086041201850417558504175586041102050457260504173505d41706a5549002010491480504575585d43f009284914001a4000009000033d504175801a445000910000205d43f0005f450000504175806041102050457260504173505d41706a5549002010491480504575805d43f009284914001a40000050417350504173505d41706a104014005f5d006a9000009e0000000000000000000000000000000100000000000002d000000000000000a00000000000000090000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000d34'; +export default '0x90000004470000000000000000000cd45dfcc00110fff3001a5c5000910005b861440006724002d0164114005b40100d360000006158000c61440001504175305f5d10a6504175305d4570a6504171385f5d1027504171385d417027134100007340001a9000001f1a445000910000085d43f0005f4500009000002b504171385d4170271341004073400024900000291a445000910000085d43f0015f4500009000002b360000001a44000050417528504175286041100850457528504170085041700860411008504170085d4100001341000073400037900000396144000c9000003b360000001a440000504174305f5d1086504174305d4570865d43f00210450440504174485f5d108961440001504175405f5d10a8504175405d4570a8504171405f5d1028504171405d417028134100007340004f900000541a445000910000085d43f0005f45000090000060504171405d41702813410040734000599000005e1a445000910000085d43f0015f45000090000060360000001a44000050417538504175386041100850457538504170005041700060411008504170005d410000134100007340006c9000006e6144000690000078504170005d410000134100407340007390000076360000001a44000090000078360000001a4400005d43f00220451400504173805f5d1070504174485d497089504173805d4170701a445000910000105f4520005f450001504175a8504175a8604110105d47f00326440000504470015041726050417260604110a026000000504070011a445000910000105f4500005f440001504174785041747860411010504173505f5c006a5d47f0025d43f00412451400504173005f5d1060504173505d45706a504173005d41706016411400734000a4900000b150496000504173505d41706a5545009010452440504170785041707860411090504170785d41000013410040734001249000031f504972601a445000910000a050411000604120a05041748850417488604110a026000000504070011a445000910000105f4500005f44000150417198504171986041101050517198505574885d454001504174085f5d10815d4540015d43f00310450440504173c85f5d10795d4140005d4d4001504573c85d457079154914c0734800d3900000e12644000050487001504573a85f5d207515453000734400da900000de504573a85d457075284504c0900000de504173a85d417075900000e15f510000504173c85d4170795f5100015d454000504174085d417081104504405d43f0032845540050557198505174785d41400113410000734000f1900000f35d4150019000011c5d455001504174105f5d10825d4550015d41400110450440504173d05f5d107a5d4150005d4d5001504573d05d45707a154914c073480102900001102644000050487001504573b05f5d207615453000734401099000010d504573b05d457076284504c09000010d504173b05d417076900001105f550000504173d05d41707a5f5500015d4940005d455000504174105d417082104504405d414001284524005d417082504171985d450000504171985d41000125450000504574885d43f003254500005041707850450008504171a8504171a860411088504171a850450028504171085041710860411018504171085d41000013410000734001339000013f504171085d450002504175485f5d10a9504175485d4970a91a445000910000185d43f0005f4500005f4520029000017b504171085d41000013410040734001449000016050417108504100085d450000504173e85f5d107d50417108504100085d450001504173785f5d106f504175a85d450000504173e85d41707d10450440504173785d41706f1a485000910000105f4910005f4900011a445000910000185d43f0015f45000050411008604120109000017b50417108504100085d450000504173f05f5d107e50417108504100085d450001504173905f5d1072504175a85d450000504173f05d41707e10450440504173905d4170721a485000910000105f4910005f4900011a445000910000185d43f0015f4500005041100860412010504173085041730860411018504171a850550000504171a85d51000450457308504171a8504d0040504170105041701060411018504170105d410000134100007340018d90000194504170105d450002504175505f5d10aa504175505d4570aa900001a8504170105d4100001341004073400199900001a150417010504100085d450000504174385f5d1087504174385d457087900001a850417010504100085d450000504174505f5d108a504174505d45708a504173205f5d1064504173205d4970641a4450009100003050411000604150205f4540045f45200550417230504172306041103050453000504170285041702860411010504170285d41000013410040734001be900001c5504170285d450001504171485f5d1029504171485d457029900001cd504170285d41000013410000734001ca900001cc1a440000900001cd1a440000504171505f5d102a50453010504170385041703860411028504170385d41000013410040734001d8900001df504170385045000850417358504173586041102050497358900001f1504170385d41000013410000734001e4900001eb1a485000910000205d47f00a104513005041200060411020900001f11a485000910000205d47f00a10451300504120006041102050417158504171586041202050453038504170605041706060411010504170605d41000013410040734001fd90000204504170605d450001504173405f5d1068504173405d4570689000020c504170605d41000013410000734002099000020b1a44a0009000020c1a44a000504173485f5d1069504d7230504171505d49702a50457158504173485d4170692d4d24501a44e000504170705f5d100e504170705d41700e134100007340021d900002281a44d000504175785f5d10af504175785d4570af1a485000910000185d43f0005f4900005f4910029000023d504170705d45700e504173885f5d10711a44d000504174585f5d108b504174585d49708b504173885d4170711a445000910000105f4520005f4500011a485000910000185d43f0015f490000504120086041101050417460504174606041201850457460504171205041712060411018504171205d410000134100007340024990000255504171205d450002504175a05f5d10b4504175a05d4970b41a445000910000185d43f0005f4500005f45200290000309504171205d410000134100407340025a900002b250417120504100085d450000504174285f5d108550417120504100085d450001504173985f5d1073504174285d497085504173985d4170731a445000910000105f4520005f45000150417178504171786041101050557478505171785d4140011341000073400275900002775d455001900002a15d455001504174185f5d10835d4550015d41400110450440504173d85f5d107b5d4150005d4d5001504573d85d45707b154914c073480286900002942644000050487001504573b85f5d2077154530007344028d90000291504573b85d457077284504c090000291504173b85d417077900002945f550000504173d85d41707b5f5500015d4940005d455000504174185d417083104504405d41400128452400504174185d457083504173f85f5d107f504173f85d45707f504173985d4170731a485000910000105f4910005f4900011a445000910000185d43f0015f45000050411008604120109000030950417120504100085d450000504174405f5d108850417120504100085d450001504173a05f5d1074504174405d497088504173a05d4170741a445000910000105f4520005f45000150417188504171886041101050557478505171885d41400113410000734002cd900002cf5d455001900002f95d455001504174205f5d10845d4550015d41400110450440504173e05f5d107c5d4150005d4d5001504573e05d45707c154914c0734802de900002ec2644000050487001504573c05f5d207815453000734402e5900002e9504573c05d457078284504c0900002e9504173c05d417078900002ec5f550000504173e05d41707c5f5500015d4940005d455000504174205d417084104504405d41400128452400504174205d457084504174005f5d1080504174005d457080504173a05d4170741a485000910000105f4910005f4900011a445000910000185d43f0015f4500005041100860412010504173285041732860411018504973281a445000910000205d43f0015f450000504110086041201850417558504175586041102050457260504173505d41706a5549002010491480504575585d43f009284914009000032e504175801a445000910000205d43f0005f450000504175806041102050457260504173505d41706a5549002010491480504575805d43f0092849140050417350504173505d41706a104014005f5d006a9000009d470000000000000000000000000000000000000100000000000002d000000000000000a00000000000000090000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000cfc'; diff --git a/packages/contract/src/contracts/multicall/static-out/multicall.bin b/packages/contract/src/contracts/multicall/static-out/multicall.bin index 55b6b58e08b86a111442eac9254c95e609f7be51..7928dc026cde86a30b1eed98702610eb160c7eb3 100644 GIT binary patch delta 761 zcmYjPO=uHA6rP#vHh&vf&|rxvi69b*7(q)s7~Rn0258|OB#6!`8MK6Ma-z1S{VVL*5Z{9cGzBk>(l(}q;4Q@ z3Pd)gjeQ5gh+@!u3eCm7Ca?sS{$lS`$v8p{mMMuLbpd!yhW{%dGiJED@q3U zk9BY|Gq?$V!e4`VlR$T{cj!_uJN^;TXPi2zTo!`wX}wC)POHhvG`Jnj4JmYy`$q4A zqlP9CoITC|HkdGQt^~gv^$z@&^$x#fa8{4&`-KaEo{4Cp_y{h9MJja897B|$1mNfzj9cqZeqY zxQ8)qz*4P0CSVCH{hF?$8<83h)33;EtONXZApD!k(R^VGneRi&Z7A0V%3r~4L%9v* x`apRb%55mubscr1n`l7NIHmJcw2Z z^l0FL2!0hokWw)9l#7rH@SJwGAblN8GA2_wE}i^~ zv^!EXok^BYvTbNPD(5=6;+W%YhAqaB`>a-JBX8%5s-CKz$Z@-%V}Do9EIg2x3KiG3 z_+gu|yv6>&v*+59*BC!Wo1VC%BO2!3ZwZ-qe)*>+d;HT8Q-wE5ARgx7Rvh_%1^5KhWS3;L$vNYaYppjm+yVbZvMRvSfhk_vj1pQB~{j&>RQYjo5fGY4_- zk!~BsbttbX>z@tYMzrWUYMx@1w*7JE9-^l`^K4+A<@P)U+ASVpo(-I-+?}U*)R|`k z^DL`+lKo{qNE`jL!H?K~Y7;ztlo*IR-;mksAv8g#bO=A7{Q{v0LZyfByF+M#P*L?% oAK1`U690l}x)n$q={O{MCgGYhtPo4PYz|-S6M7%GB7&#>0t~+HzW@LL From 542b95207db60f75e98626bb8bb7bdc592d889a6 Mon Sep 17 00:00:00 2001 From: Luiz Estacio Date: Thu, 1 Sep 2022 21:18:44 -0300 Subject: [PATCH 14/17] chore: prettify --- .../src/contracts/multicall/static-out/multicall-abi.json | 2 +- .../contracts/multicall/static-out/multicall-flat-abi.json | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/packages/contract/src/contracts/multicall/static-out/multicall-abi.json b/packages/contract/src/contracts/multicall/static-out/multicall-abi.json index d8d6d045853..10aa476507d 100644 --- a/packages/contract/src/contracts/multicall/static-out/multicall-abi.json +++ b/packages/contract/src/contracts/multicall/static-out/multicall-abi.json @@ -441,4 +441,4 @@ } ] } -] \ No newline at end of file +] diff --git a/packages/contract/src/contracts/multicall/static-out/multicall-flat-abi.json b/packages/contract/src/contracts/multicall/static-out/multicall-flat-abi.json index e2fe23fc569..e4d163f8ac0 100644 --- a/packages/contract/src/contracts/multicall/static-out/multicall-flat-abi.json +++ b/packages/contract/src/contracts/multicall/static-out/multicall-flat-abi.json @@ -97,9 +97,7 @@ "typeArguments": null } ], - "typeParameters": [ - 7 - ] + "typeParameters": [7] }, { "typeId": 7, @@ -234,4 +232,4 @@ } } ] -} \ No newline at end of file +} From 328158f3d91473278656c20f0415a48ed9d76301 Mon Sep 17 00:00:00 2001 From: Luiz Estacio Date: Thu, 1 Sep 2022 21:23:42 -0300 Subject: [PATCH 15/17] chore: add changeset --- .changeset/tidy-bulldogs-tap.md | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 .changeset/tidy-bulldogs-tap.md diff --git a/.changeset/tidy-bulldogs-tap.md b/.changeset/tidy-bulldogs-tap.md new file mode 100644 index 00000000000..1b7dcacc4f8 --- /dev/null +++ b/.changeset/tidy-bulldogs-tap.md @@ -0,0 +1,11 @@ +--- +"@fuel-ts/abi-coder": minor +"@fuel-ts/contract": minor +"@fuel-ts/providers": minor +"@fuel-ts/testcases": minor +"@fuel-ts/transactions": minor +"@fuel-ts/wallet": minor +"@fuel-ts/wallet-manager": minor +--- + +Upgrade compatibility to fuel-core v0.10.1 From 67eb0ff0d54f3f45038ee4640bf702ec4b7aa723 Mon Sep 17 00:00:00 2001 From: Luiz Estacio Date: Thu, 1 Sep 2022 21:26:35 -0300 Subject: [PATCH 16/17] chore: comment build multicall --- packages/contract/scripts/build-forc-projects.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/contract/scripts/build-forc-projects.sh b/packages/contract/scripts/build-forc-projects.sh index eec1e5304cd..e73ef2ee589 100755 --- a/packages/contract/scripts/build-forc-projects.sh +++ b/packages/contract/scripts/build-forc-projects.sh @@ -2,7 +2,7 @@ set -euo pipefail -scripts/build-multicall.sh +# scripts/build-multicall.sh pnpm forc build -p src/__test__/storage-test-contract pnpm forc build -p src/__test__/call-test-contract pnpm forc build -p src/__test__/token-test-contract/token_abi From 258a073fb0eea80f2696fe05a9535b1819b49d6f Mon Sep 17 00:00:00 2001 From: Luiz Estacio Date: Thu, 1 Sep 2022 21:40:33 -0300 Subject: [PATCH 17/17] feat: update predicate to sway 0.22.1 --- packages/predicate/src/test-predicate-address/src/main.sw | 4 ++-- packages/predicate/src/test-predicate-struct/src/main.sw | 4 ++-- packages/predicate/src/test-predicate-u32/src/main.sw | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/predicate/src/test-predicate-address/src/main.sw b/packages/predicate/src/test-predicate-address/src/main.sw index 14bfc327e2b..96dde76e4f5 100644 --- a/packages/predicate/src/test-predicate-address/src/main.sw +++ b/packages/predicate/src/test-predicate-address/src/main.sw @@ -1,9 +1,9 @@ predicate; -use std::tx::get_predicate_data; +use std::inputs::input_predicate_data; fn main() -> bool { - let received: b256 = get_predicate_data(); + let received: b256 = input_predicate_data(0); let expected: b256 = 0xef86afa9696cf0dc6385e2c407a6e159a1103cefb7e2ae0636fb33d3cb2a9e4a; received == expected diff --git a/packages/predicate/src/test-predicate-struct/src/main.sw b/packages/predicate/src/test-predicate-struct/src/main.sw index 6acd779b37d..4fb3eaf6518 100644 --- a/packages/predicate/src/test-predicate-struct/src/main.sw +++ b/packages/predicate/src/test-predicate-struct/src/main.sw @@ -1,6 +1,6 @@ predicate; -use std::tx::get_predicate_data; +use std::inputs::input_predicate_data; struct Validation { has_account: bool, @@ -8,7 +8,7 @@ struct Validation { } fn main() -> bool { - let received: Validation = get_predicate_data(); + let received: Validation = input_predicate_data(0); let expected_has_account: bool = true; let expected_total_complete: u64 = 100; diff --git a/packages/predicate/src/test-predicate-u32/src/main.sw b/packages/predicate/src/test-predicate-u32/src/main.sw index adf6c2b98b8..bf0b0a6ae1c 100644 --- a/packages/predicate/src/test-predicate-u32/src/main.sw +++ b/packages/predicate/src/test-predicate-u32/src/main.sw @@ -1,9 +1,9 @@ predicate; -use std::tx::get_predicate_data; +use std::inputs::input_predicate_data; fn main() -> bool { - let received: u32 = get_predicate_data(); + let received: u32 = input_predicate_data(0); let expected: u32 = 1078; received == expected