Skip to content

Commit

Permalink
Merge pull request #182 from NearSocial/pass-big
Browse files Browse the repository at this point in the history
Support Big and BN during a deepCopy
  • Loading branch information
evgenykuzyakov committed Apr 20, 2024
2 parents 8dbb065 + 1df4763 commit c7346d6
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## Pending

- Support `Big` and `BN` during a deep copy.
- Fix typo.

## 2.6.0

- Support multiple Limited Access Keys on BOS gateway to enable "Don't ask me again" when interacting with third-party contracts on BOS. See https://github.com/NearSocial/VM/issues/148
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

17 changes: 11 additions & 6 deletions src/lib/data/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import Big from "big.js";
import React from "react";
import equal from "deep-equal";
import { ethers } from "ethers";
import { BN } from "bn.js";

export const TGas = Big(10).pow(12);
export const MaxGasPerTransaction = TGas.mul(250);
Expand All @@ -13,11 +14,11 @@ const ValidAccountRe = /^(([a-z\d]+[-_])*[a-z\d]+\.)*([a-z\d]+[-_])*[a-z\d]+$/;
export const OneNear = Big(10).pow(24);
const AccountSafetyMargin = OneNear.div(2);
export const ErrorScopes = {
"Boundary": "Component triggered an Error Boundary",
"Compliation": "Compilation error",
"Execution": "Execution error",
"Render": "Render error",
"Source": "Source code not found"
Boundary: "Component triggered an Error Boundary",
Compilation: "Compilation error",
Execution: "Execution error",
Render: "Render error",
Source: "Source code not found",
};

export const Loading = (
Expand Down Expand Up @@ -382,7 +383,11 @@ export const deepCopy = (o) => {
return new Blob([o], { type: o.type });
} else if (o instanceof Uint8Array || o instanceof ArrayBuffer) {
return o.slice(0);
} else if (o instanceof ethers.BigNumber) {
} else if (
o instanceof ethers.BigNumber ||
o instanceof BN ||
o instanceof Big
) {
return o;
} else if (o instanceof Date) {
return new Date(o);
Expand Down

0 comments on commit c7346d6

Please sign in to comment.