Skip to content

Commit

Permalink
chore: merge origin/main
Browse files Browse the repository at this point in the history
  • Loading branch information
kieranroneill committed Oct 3, 2024
2 parents a059343 + d9306f1 commit 1d6ef3b
Show file tree
Hide file tree
Showing 22 changed files with 84 additions and 90 deletions.
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/bug_report_template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ body:
label: Version
description: What version of the software are you running?
options:
- 2.3.1
- 2.3.0
- 2.2.1
- 2.2.0
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@

* change icon of account ([#335](https://github.com/agoralabs-sh/kibisis-web-extension/issues/335)) ([0174529](https://github.com/agoralabs-sh/kibisis-web-extension/commit/01745293a5f54ca0274b971251b4eaf12a4de9a4))

## [2.3.1](https://github.com/agoralabs-sh/kibisis-web-extension/compare/v2.3.0...v2.3.1) (2024-10-03)


### Bug Fixes

* use fixed integers in atomic unit bignumber conversions ([#337](https://github.com/agoralabs-sh/kibisis-web-extension/issues/337)) ([ee33fab](https://github.com/agoralabs-sh/kibisis-web-extension/commit/ee33fab67ed8d6aa8d154815eb750589151b420d))

# [2.3.0](https://github.com/agoralabs-sh/kibisis-web-extension/compare/v2.2.1...v2.3.0) (2024-09-30)


Expand Down
32 changes: 15 additions & 17 deletions src/extension/contracts/ARC0072Contract/ARC0072Contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,8 @@ export default class ARC0072Contract extends BaseContract {
// if the first arg, owner, is not an address
if (!abiAddressArgType || abiAddressArgType.toString() !== 'address') {
throw new InvalidABIContractError(
this._appId.toString(),
`application "${this._appId.toString()}" not valid as method "${
ARC0072MethodEnum.BalanceOf
}" has an invalid "owner" type`
this._appId,
`application "${this._appId}" not valid as method "${ARC0072MethodEnum.BalanceOf}" has an invalid "owner" type`
);
}

Expand All @@ -79,8 +77,8 @@ export default class ARC0072Contract extends BaseContract {

if (!result) {
throw new InvalidABIContractError(
this._appId.toString(),
`application "${this._appId.toString()}" not valid because the result returned "null"`
this._appId,
`application "${this._appId}" not valid because the result returned "null"`
);
}

Expand All @@ -104,7 +102,7 @@ export default class ARC0072Contract extends BaseContract {
try {
abiMethod = this._abi.getMethodByName(ARC0072MethodEnum.OwnerOf);
encodedTokenId = (abiMethod.args[0].type as ABIType).encode(
BigInt(tokenId.toString())
BigInt(tokenId.toFixed())
);
result = (await this.readByMethod({
abiMethod,
Expand All @@ -120,8 +118,8 @@ export default class ARC0072Contract extends BaseContract {

if (!result) {
throw new InvalidABIContractError(
this._appId.toString(),
`application "${this._appId.toString()}" not valid because the result returned "null"`
this._appId,
`application "${this._appId}" not valid because the result returned "null"`
);
}

Expand Down Expand Up @@ -149,7 +147,7 @@ export default class ARC0072Contract extends BaseContract {
try {
abiMethod = this._abi.getMethodByName(ARC0072MethodEnum.TokenByIndex);
encodedIndex = (abiMethod.args[0].type as ABIType).encode(
BigInt(index.toString())
BigInt(index.toFixed())
);
result = (await this.readByMethod({
abiMethod,
Expand All @@ -165,8 +163,8 @@ export default class ARC0072Contract extends BaseContract {

if (!result) {
throw new InvalidABIContractError(
this._appId.toString(),
`application "${this._appId.toString()}" not valid because the result returned "null"`
this._appId,
`application "${this._appId}" not valid because the result returned "null"`
);
}

Expand All @@ -189,7 +187,7 @@ export default class ARC0072Contract extends BaseContract {
try {
abiMethod = this._abi.getMethodByName(ARC0072MethodEnum.TokenURI);
encodedTokenId = (abiMethod.args[0].type as ABIType).encode(
BigInt(tokenId.toString())
BigInt(tokenId.toFixed())
);
result = (await this.readByMethod({
abiMethod,
Expand All @@ -205,8 +203,8 @@ export default class ARC0072Contract extends BaseContract {

if (!result) {
throw new InvalidABIContractError(
this._appId.toString(),
`application "${this._appId.toString()}" not valid because the result returned "null"`
this._appId,
`application "${this._appId}" not valid because the result returned "null"`
);
}

Expand Down Expand Up @@ -239,8 +237,8 @@ export default class ARC0072Contract extends BaseContract {

if (!result) {
throw new InvalidABIContractError(
this._appId.toString(),
`application "${this._appId.toString()}" not valid because the result returned "null"`
this._appId,
`application "${this._appId}" not valid because the result returned "null"`
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,10 @@ describe.skip(`${__dirname}#ARC0200Contract`, () => {
const result: IARC0200AssetInformation = await contract.metadata();

// assert
expect(result.decimals).toBe(BigInt(String(decimals.toString())));
expect(result.decimals).toBe(BigInt(decimals.toFixed()));
expect(result.name).toBe(name);
expect(result.symbol).toBe(symbol);
expect(result.totalSupply).toBe(BigInt(String(totalSupply.toString())));
expect(result.totalSupply).toBe(BigInt(totalSupply.toFixed()));
});
});

Expand Down
52 changes: 23 additions & 29 deletions src/extension/contracts/ARC0200Contract/ARC0200Contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,8 @@ export default class ARC0200Contract extends BaseContract {
// if the first arg, owner, is not an address
if (!abiAddressArgType || abiAddressArgType.toString() !== 'address') {
throw new InvalidABIContractError(
this._appId.toString(),
`application "${this._appId.toString()}" not valid as method "${
ARC0200MethodEnum.BalanceOf
}" has an invalid "owner" type`
this._appId,
`application "${this._appId}" not valid as method "${ARC0200MethodEnum.BalanceOf}" has an invalid "owner" type`
);
}

Expand All @@ -96,8 +94,8 @@ export default class ARC0200Contract extends BaseContract {

if (!result) {
throw new InvalidABIContractError(
this._appId.toString(),
`application "${this._appId.toString()}" not valid because the result returned "null"`
this._appId,
`application "${this._appId}" not valid because the result returned "null"`
);
}

Expand Down Expand Up @@ -133,10 +131,8 @@ export default class ARC0200Contract extends BaseContract {
abiMethod.args[0].type.toString() !== 'address'
) {
throw new InvalidABIContractError(
this._appId.toString(),
`application "${this._appId.toString()}" not valid as method "${
ARC0200MethodEnum.Transfer
}" has an invalid "to" type`
this._appId,
`application "${this._appId}" not valid as method "${ARC0200MethodEnum.Transfer}" has an invalid "to" type`
);
}

Expand All @@ -146,15 +142,13 @@ export default class ARC0200Contract extends BaseContract {
abiMethod.args[1].type.toString() !== 'uint256'
) {
throw new InvalidABIContractError(
this._appId.toString(),
`application "${this._appId.toString()}" not valid as method "${
ARC0200MethodEnum.Transfer
}" has an invalid "value" type`
this._appId,
`application "${this._appId}" not valid as method "${ARC0200MethodEnum.Transfer}" has an invalid "value" type`
);
}

encodedAmount = (abiMethod.args[1].type as ABIType).encode(
BigInt(String(amountInAtomicUnits.toString()))
BigInt(amountInAtomicUnits.toFixed())
);
encodedToAddress = (abiMethod.args[0].type as ABIType).encode(toAddress);
appArgs = [encodedToAddress, encodedAmount];
Expand Down Expand Up @@ -187,10 +181,10 @@ export default class ARC0200Contract extends BaseContract {
paymentTransaction = makePaymentTxnWithSuggestedParams(
fromAddress,
this.applicationAddress(), // send funds to application account
BigInt(String(boxStorageAmount.toString())),
BigInt(boxStorageAmount.toFixed()),
undefined,
new TextEncoder().encode(
`initial box storage funding for account "${toAddress}" in application "${this._appId.toString()}"`
`initial box storage funding for account "${toAddress}" in application "${this._appId}"`
),
suggestedParams
);
Expand Down Expand Up @@ -254,8 +248,8 @@ export default class ARC0200Contract extends BaseContract {

if (!result) {
throw new InvalidABIContractError(
this._appId.toString(),
`application "${this._appId.toString()}" not valid because the result returned "null"`
this._appId,
`application "${this._appId}" not valid because the result returned "null"`
);
}

Expand Down Expand Up @@ -301,7 +295,7 @@ export default class ARC0200Contract extends BaseContract {

if (response.txnGroups[0].failureMessage) {
throw new ReadABIContractError(
this._appId.toString(),
this._appId,
response.txnGroups[0].failureMessage
);
}
Expand All @@ -323,8 +317,8 @@ export default class ARC0200Contract extends BaseContract {
// if any are null, the application is not a valid arc-0200 application
if (results.some((value) => !value)) {
throw new InvalidABIContractError(
this._appId.toString(),
`application "${this._appId.toString()}" not valid because a result returned "null"`
this._appId,
`application "${this._appId}" not valid because a result returned "null"`
);
}

Expand All @@ -335,7 +329,7 @@ export default class ARC0200Contract extends BaseContract {
decimals: (decimalResult as BigNumber).toNumber(),
name: this.trimNullBytes(nameResult as string),
symbol: this.trimNullBytes(symbolResult as string),
totalSupply: (totalSupplyResult as BigNumber).toString(),
totalSupply: (totalSupplyResult as BigNumber).toFixed(),
};
}

Expand Down Expand Up @@ -365,8 +359,8 @@ export default class ARC0200Contract extends BaseContract {

if (!result) {
throw new InvalidABIContractError(
this._appId.toString(),
`application "${this._appId.toString()}" not valid because the result returned "null"`
this._appId,
`application "${this._appId}" not valid because the result returned "null"`
);
}

Expand Down Expand Up @@ -399,8 +393,8 @@ export default class ARC0200Contract extends BaseContract {

if (!result) {
throw new InvalidABIContractError(
this._appId.toString(),
`application "${this._appId.toString()}" not valid because the result returned "null"`
this._appId,
`application "${this._appId}" not valid because the result returned "null"`
);
}

Expand Down Expand Up @@ -433,8 +427,8 @@ export default class ARC0200Contract extends BaseContract {

if (!result) {
throw new InvalidABIContractError(
this._appId.toString(),
`application "${this._appId.toString()}" not valid because the result returned "null"`
this._appId,
`application "${this._appId}" not valid because the result returned "null"`
);
}

Expand Down
18 changes: 6 additions & 12 deletions src/extension/contracts/BaseContract/BaseContract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,11 +202,7 @@ export default class BaseContract {

if (!log) {
this._logger.debug(
`${
BaseContract.name
}#${_functionName}: no log found for application "${this._appId.toString()}" and method "${
abiMethod.name
}"`
`${BaseContract.name}#${_functionName}: no log found for application "${this._appId}" and method "${abiMethod.name}"`
);

return null;
Expand Down Expand Up @@ -246,7 +242,7 @@ export default class BaseContract {
appArgs,
suggestedParams,
}: IBaseApplicationOptions): Promise<IABIResult | null> {
const _functionName: string = 'readByMethod';
const _functionName = 'readByMethod';
let response: algosdk.modelsv2.SimulateResponse;
let transaction: Transaction;

Expand All @@ -265,7 +261,7 @@ export default class BaseContract {

if (response.txnGroups[0].failureMessage) {
throw new ReadABIContractError(
this._appId.toString(),
this._appId,
response.txnGroups[0].failureMessage
);
}
Expand Down Expand Up @@ -293,9 +289,7 @@ export default class BaseContract {
protected async simulateTransactions(
simulateTransactions: ISimulateTransaction[]
): Promise<algosdk.modelsv2.SimulateResponse> {
const transactions: Transaction[] = simulateTransactions.map(
(value) => value.transaction
);
const transactions = simulateTransactions.map((value) => value.transaction);
let request: algosdk.modelsv2.SimulateRequest;

assignGroupID(transactions);
Expand Down Expand Up @@ -346,7 +340,7 @@ export default class BaseContract {
* @returns {string} the base32 encoded address for the application.
*/
public applicationAddress(): string {
return getApplicationAddress(BigInt(this._appId.toString()));
return getApplicationAddress(BigInt(this._appId));
}

/**
Expand All @@ -362,7 +356,7 @@ export default class BaseContract {
public async boxByName(
name: Uint8Array
): Promise<algosdk.modelsv2.Box | null> {
const _functionName: string = 'boxByName';
const _functionName = 'boxByName';

try {
return await this._algod
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ const createUnsignedTransactionsThunk: AsyncThunk<
amountInAtomicUnits = convertToAtomicUnit(
new BigNumber(amountInStandardUnits),
asset.decimals
).toString(); // convert to atomic units
).toFixed(); // convert to atomic units

switch (asset.type) {
case AssetTypeEnum.ARC0200:
Expand Down
2 changes: 1 addition & 1 deletion src/extension/hooks/useAmountInput/useAmountInput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default function useAmountInput({ label, required }: IOptions): IState {

// if the entered value is greater than the maximum allowed, use the max
if (_value.gt(maximumAmountInStandardUnits)) {
setValue(_value.toString());
setValue(_value.toFixed());

return;
}
Expand Down
4 changes: 2 additions & 2 deletions src/extension/modals/SendAssetModal/SendAssetModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -552,11 +552,11 @@ const SendAssetModal: FC<IModalProps> = ({ onClose }) => {
network,
});

setMaximumAmountInAtomicUnits(_maximumAmountInAtomicUnits.toString());
setMaximumAmountInAtomicUnits(_maximumAmountInAtomicUnits.toFixed());

// if the amount exceeds the new maximum transaction amount, set the amount to the maximum transaction amount
if (new BigNumber(amountValue).gt(_maximumAmountInAtomicUnits)) {
setAmountValue(_maximumAmountInAtomicUnits.toString());
setAmountValue(_maximumAmountInAtomicUnits.toFixed());

return;
}
Expand Down
4 changes: 2 additions & 2 deletions src/extension/models/NetworkClient/NetworkClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ export default class NetworkClient {

return {
id: assetID,
amount: result.toString(),
amount: result.toFixed(),
type: AssetTypeEnum.ARC0200,
};
},
Expand Down Expand Up @@ -213,7 +213,7 @@ export default class NetworkClient {
totalSupply = await contract.totalSupply();

return {
totalSupply: BigInt(totalSupply.toString()),
totalSupply: BigInt(totalSupply.toFixed()),
};
} catch (error) {
switch (error.code) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ describe(`${__dirname}/calculateMinimumBalanceRequirementForStandardAssets`, ()
}: ITestParams) => {
account.networkInformation[encodedGenesisHash] = {
...account.networkInformation[encodedGenesisHash],
minAtomicBalance: minBalanceInAtomicUnits.toString(),
minAtomicBalance: minBalanceInAtomicUnits.toFixed(),
};

expect(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default function mapARC0072AssetFromARC0072AssetInformation(
id: appId,
totalSupply: new BigNumber(
String(assetInformation.totalSupply as bigint)
).toString(),
).toFixed(),
type: AssetTypeEnum.ARC0072,
verified,
};
Expand Down
Loading

0 comments on commit 1d6ef3b

Please sign in to comment.