-
Notifications
You must be signed in to change notification settings - Fork 332
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Feature: Add Polygon ERC20 importers for exchange
- Loading branch information
Showing
7 changed files
with
61 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@ledgerhq/cryptoassets": minor | ||
--- | ||
|
||
Adding support for polygon ERC20 exchange importing |
43 changes: 43 additions & 0 deletions
43
libs/ledgerjs/packages/cryptoassets/src/crypto-assets-importer/exchange/polygon-erc20.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import fs from "fs"; | ||
import { fetchTokens } from "../fetch"; | ||
|
||
type PolygonERC20Exchange = [string, string, string]; | ||
|
||
export const importPolygonERC20Exchange = async (outputDir: string) => { | ||
console.log("importing Polygon-ERC20 exchange..."); | ||
try { | ||
const [polygonERC20Exchange, hash] = await fetchTokens<PolygonERC20Exchange>( | ||
"evm/137/erc20-exchange.json", | ||
); | ||
fs.writeFileSync( | ||
`${outputDir}/exchange/polygon-erc20.json`, | ||
JSON.stringify(polygonERC20Exchange), | ||
); | ||
if (hash) { | ||
fs.writeFileSync(`${outputDir}/exchange/polygon-erc20-hash.json`, JSON.stringify(hash)); | ||
} | ||
|
||
const polygonerc20typeStringified = `export type PolygonERC20Exchange = [string, string, string];`; | ||
const hashStringified = hash | ||
? `export { default as hash } from "./polygon-erc20-hash.json";` | ||
: ""; | ||
const exchangesStringified = `import exchanges from "./polygon-erc20.json";`; | ||
const exportStringified = `export default exchanges as PolygonERC20Exchange[];`; | ||
|
||
fs.writeFileSync( | ||
`${outputDir}/exchange/polygon-erc20.ts`, | ||
`${polygonerc20typeStringified} | ||
${hashStringified} | ||
${exchangesStringified} | ||
${exportStringified} | ||
`, | ||
); | ||
|
||
console.log("importing Polygon-ERC20 exchange success"); | ||
} catch (err) { | ||
console.error(err); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
libs/ledgerjs/packages/cryptoassets/src/data/exchange/polygon-erc20-hash.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
"\"8f79337368e2cde5075fa2ddb1b3361a\"" |
1 change: 1 addition & 0 deletions
1
libs/ledgerjs/packages/cryptoassets/src/data/exchange/polygon-erc20.json
Large diffs are not rendered by default.
Oops, something went wrong.
7 changes: 7 additions & 0 deletions
7
libs/ledgerjs/packages/cryptoassets/src/data/exchange/polygon-erc20.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export type PolygonERC20Exchange = [string, string, string]; | ||
|
||
export { default as hash } from "./polygon-erc20-hash.json"; | ||
|
||
import exchanges from "./polygon-erc20.json"; | ||
|
||
export default exchanges as PolygonERC20Exchange[]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters