Skip to content

Commit

Permalink
fix: remove buffer dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
elliotBraem committed Oct 22, 2024
1 parent 709d004 commit a128344
Show file tree
Hide file tree
Showing 7 changed files with 3,297 additions and 4,359 deletions.
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
"husky": "^9.0.11",
"jest": "^29.7.0",
"lint-staged": "^15.2.2",
"near-api-js": "^5.0.1",
"near-sandbox": "0.0.18",
"prettier": "^3.2.5",
"prism-react-renderer": "^2.3.1",
Expand All @@ -105,12 +106,13 @@
"@near-js/keystores": "^0.2.1",
"@near-js/providers": "^1.0.1",
"@near-js/transactions": "^1.3.1",
"@near-js/utils": "^1.0.1",
"bignumber.js": "^9.1.2",
"near-api-js": "^5.0.1",
"tsup": "^8.3.0"
},
"resolutions": {
"braces": "^3.0.3",
"ws": "^8.17.1"
"ws": "^8.17.1",
"base-x": "3.0.0"
}
}
2 changes: 2 additions & 0 deletions src/constants/Fees.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ export const GAS_FEE_IN_ATOMIC_UNITS = '30000000000000';
export const MINIMUM_STORAGE_IN_BYTES = '2000';
export const ONE_YOCTO = '1';
export const STORAGE_COST_PER_BYTES_IN_ATOMIC_UNITS = '10000000000000000000';

export const NEAR_NOMINATION_EXP = '24';
3 changes: 2 additions & 1 deletion src/utils/convertNEARToYoctoNEAR/convertNEARToYoctoNEAR.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { NEAR_NOMINATION_EXP } from '@near-js/utils';
import BigNumber from 'bignumber.js';

const NEAR_NOMINATION_EXP = '24';

/**
* Convenience function that converts a NEAR amount (standard unit) to the yoctoNEAR amount (atomic unit).
* @param {string} standardAmount - the NEAR amount to convert.
Expand Down
2 changes: 1 addition & 1 deletion src/utils/convertYoctoNEARToNEAR/convertYoctoNEARToNEAR.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { NEAR_NOMINATION_EXP } from '@near-js/utils';
import { NEAR_NOMINATION_EXP } from '@app/constants';
import BigNumber from 'bignumber.js';

/**
Expand Down
10 changes: 1 addition & 9 deletions src/utils/rpcQueries/viewFunction/viewFunction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,6 @@ function parseJsonFromRawResponse(response: Uint8Array): ViewFunctionResult {
return JSON.parse(new TextDecoder().decode(response));
}

function base64Encode(str: string): string {
try {
return btoa(str);
} catch (err) {
return Buffer.from(str).toString('base64');
}
}

export default async function viewFunction({
args = {},
contractId,
Expand All @@ -34,7 +26,7 @@ export default async function viewFunction({
request_type: 'call_function',
account_id: contractId,
method_name: method,
args_base64: base64Encode(JSON.stringify(args)),
args_base64: btoa(JSON.stringify(args)),
finality: 'optimistic',
});

Expand Down
2 changes: 0 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,13 @@
"allowUnreachableCode": false,
"alwaysStrict": true,
"baseUrl": "./",
// "composite": true,
"declaration": true,
"declarationMap": true,
"emitDecoratorMetadata": true,
"esModuleInterop": true,
"experimentalDecorators": true,
"forceConsistentCasingInFileNames": true,
"incremental": false,
// "tsBuildInfoFile": "./dist/.tsbuildinfo",
"lib": ["DOM", "ESNext"],
"module": "ES2022",
"moduleResolution": "node",
Expand Down
7,631 changes: 3,287 additions & 4,344 deletions yarn.lock

Large diffs are not rendered by default.

0 comments on commit a128344

Please sign in to comment.