From 2cb4aa1029eb246e22cab7dcdcf189bfd6137dd7 Mon Sep 17 00:00:00 2001 From: Dexter Date: Fri, 12 May 2023 08:59:15 +0100 Subject: [PATCH] fix: claim not encoding ascii correctly --- libs/smart-contracts/src/contracts/claim.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/libs/smart-contracts/src/contracts/claim.ts b/libs/smart-contracts/src/contracts/claim.ts index 8dd7c7606..f51ae0c32 100644 --- a/libs/smart-contracts/src/contracts/claim.ts +++ b/libs/smart-contracts/src/contracts/claim.ts @@ -1,5 +1,5 @@ import { ethers } from 'ethers'; -import { hexlify } from 'ethers/lib/utils'; +import { hexlify, toUtf8Bytes } from 'ethers/lib/utils'; import abi from '../abis/claim_abi.json'; import { calcGasBuffer } from '../utils'; @@ -70,7 +70,7 @@ export class Claim { tranche, expiry, }, - hexlify(country), + hexlify(toUtf8Bytes(country)), target, ].filter(Boolean); const res = await this.contract.estimateGas[method](...args); @@ -110,7 +110,9 @@ export class Claim { * @return {Promise} */ async isCountryBlocked(country: string): Promise { - const isAllowed = await this.contract.allowed_countries(hexlify(country)); + const isAllowed = await this.contract.allowed_countries( + hexlify(toUtf8Bytes(country)) + ); return !isAllowed; } }