Skip to content

Commit

Permalink
fix bigint
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben-Rey committed Apr 23, 2024
1 parent 247df9a commit 7cc0af2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
22 changes: 11 additions & 11 deletions packages/massa-web3/src/experimental/smartContract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ import {
import { BlockchainClient } from './client'
import { Account } from './account'

export const MAX_GAS_EXECUTE = 3980167295
export const MAX_GAS_EXECUTE = 3980167295n

interface ExecuteOption {
fee?: number
fee?: bigint
periodToLive?: number
coins?: number
maxGas?: number
coins?: bigint
maxGas?: bigint
datastore?: Map<Uint8Array, Uint8Array>
}

Expand Down Expand Up @@ -56,10 +56,10 @@ export class ByteCode {
): Promise<Operation> {
const operation = new OperationManager(privateKey, client)
const details: ExecuteOperation = {
fee: opts?.fee ?? 0,
fee: opts?.fee ?? 0n,
expirePeriod: await calculateExpirePeriod(client, opts?.periodToLive),
type: OperationType.ExecuteSmartContractBytecode,
coins: opts?.coins ?? 0,
coins: opts?.coins ?? 0n,
// TODO: implement max gas
maxGas: opts?.maxGas || MAX_GAS_EXECUTE,
contractDataBinary: byteCode,
Expand Down Expand Up @@ -123,11 +123,11 @@ function populateDatastore(
}

interface DeployOptions {
smartContractCoins?: number
fee?: number
smartContractCoins?: bigint
fee?: bigint
periodToLive?: number
coins?: number
maxGas?: number
coins?: bigint
maxGas?: bigint
waitForSpeculativeExecution?: boolean
}

Expand Down Expand Up @@ -178,7 +178,7 @@ export class SmartContract {
opts: DeployOptions
): Promise<SmartContract> {
const totalCost =
Number(StorageCost.smartContract(byteCode.length)) + opts.coins
BigInt(StorageCost.smartContract(byteCode.length)) + opts.coins

if (
(await client.getBalance(account.address.toString(), true)) < totalCost
Expand Down
6 changes: 3 additions & 3 deletions packages/massa-web3/test/experimental/smartContract.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ describe('Basic use cases', () => {
)
const byteCode = new Uint8Array([1, 2, 3, 4])
const opts = {
fee: 1,
fee: 1n,
periodToLive: 2,
coins: 3,
maxGas: 4,
coins: 3n,
maxGas: 4n,
}
const contract = await ByteCode.execute(
client,
Expand Down

0 comments on commit 7cc0af2

Please sign in to comment.