@learncard/ethereum-plugin 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +140 -0
- package/dist/ethereum-plugin.cjs.development.js +30365 -0
- package/dist/ethereum-plugin.cjs.development.js.map +7 -0
- package/dist/ethereum-plugin.cjs.production.min.js +20 -0
- package/dist/ethereum-plugin.cjs.production.min.js.map +7 -0
- package/dist/ethereum-plugin.esm.js +30361 -0
- package/dist/ethereum-plugin.esm.js.map +7 -0
- package/dist/hardcodedTokens.d.ts +22 -0
- package/dist/helpers.d.ts +7 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +7 -0
- package/dist/types.d.ts +32 -0
- package/package.json +44 -0
| @@ -0,0 +1,22 @@ | |
| 1 | 
            +
            export declare const hardcodedTokens: {
         | 
| 2 | 
            +
                name: string;
         | 
| 3 | 
            +
                address: string;
         | 
| 4 | 
            +
                symbol: string;
         | 
| 5 | 
            +
                decimals: number;
         | 
| 6 | 
            +
                chainId: number;
         | 
| 7 | 
            +
                logoURI: string;
         | 
| 8 | 
            +
                extensions: {
         | 
| 9 | 
            +
                    bridgeInfo: {
         | 
| 10 | 
            +
                        '10': {
         | 
| 11 | 
            +
                            tokenAddress: string;
         | 
| 12 | 
            +
                        };
         | 
| 13 | 
            +
                        '137': {
         | 
| 14 | 
            +
                            tokenAddress: string;
         | 
| 15 | 
            +
                        };
         | 
| 16 | 
            +
                        '42161': {
         | 
| 17 | 
            +
                            tokenAddress: string;
         | 
| 18 | 
            +
                        };
         | 
| 19 | 
            +
                    };
         | 
| 20 | 
            +
                };
         | 
| 21 | 
            +
            }[];
         | 
| 22 | 
            +
            export default hardcodedTokens;
         | 
| @@ -0,0 +1,7 @@ | |
| 1 | 
            +
            import { ethers } from 'ethers';
         | 
| 2 | 
            +
            import { Token, TokenList } from './types';
         | 
| 3 | 
            +
            export declare const isAddress: (maybeAddress: string) => boolean;
         | 
| 4 | 
            +
            export declare const formatUnits: (units: ethers.BigNumberish, symbolOrAddress: string, tokenList: TokenList, chainId: number) => Promise<string>;
         | 
| 5 | 
            +
            export declare const parseUnits: (units: string, symbolOrAddress: string, tokenList: TokenList, chainId: number) => Promise<ethers.BigNumber>;
         | 
| 6 | 
            +
            export declare const getTokenFromSymbolOrAddress: (symbolOrAddress: string, tokenList: TokenList, chainId: number) => Promise<Token | undefined>;
         | 
| 7 | 
            +
            export declare const getChainIdFromProvider: (provider: ethers.providers.Provider) => Promise<number>;
         | 
    
        package/dist/index.d.ts
    ADDED
    
    | @@ -0,0 +1,7 @@ | |
| 1 | 
            +
            import { LearnCard } from '@learncard/core';
         | 
| 2 | 
            +
            import { EthereumConfig, EthereumPlugin } from './types';
         | 
| 3 | 
            +
            export * from './types';
         | 
| 4 | 
            +
            /**
         | 
| 5 | 
            +
             * @group Plugins
         | 
| 6 | 
            +
             */
         | 
| 7 | 
            +
            export declare const getEthereumPlugin: (initLearnCard: LearnCard<any, 'id'>, config: EthereumConfig) => EthereumPlugin;
         | 
    
        package/dist/index.js
    ADDED
    
    
    
        package/dist/types.d.ts
    ADDED
    
    | @@ -0,0 +1,32 @@ | |
| 1 | 
            +
            import { providers } from 'ethers';
         | 
| 2 | 
            +
            import { Plugin } from '@learncard/core';
         | 
| 3 | 
            +
            /** @group Ethereum Plugin */
         | 
| 4 | 
            +
            export type EthereumPluginMethods = {
         | 
| 5 | 
            +
                getEthereumAddress: () => string;
         | 
| 6 | 
            +
                getBalance: (symbolOrAddress?: string) => Promise<string>;
         | 
| 7 | 
            +
                getBalanceForAddress: (walletAddress: string, symbolOrAddress?: string) => Promise<string>;
         | 
| 8 | 
            +
                transferTokens: (tokenSymbolOrAddress: string, amount: number, toAddress: string) => Promise<string>;
         | 
| 9 | 
            +
                getGasPrice: () => Promise<string>;
         | 
| 10 | 
            +
                getCurrentNetwork: () => providers.Networkish;
         | 
| 11 | 
            +
                changeNetwork: (network: providers.Networkish) => void;
         | 
| 12 | 
            +
                addInfuraProjectId: (infuraProjectIdToAdd: string) => void;
         | 
| 13 | 
            +
            };
         | 
| 14 | 
            +
            /** @group Ethereum Plugin */
         | 
| 15 | 
            +
            export type EthereumConfig = {
         | 
| 16 | 
            +
                infuraProjectId?: string;
         | 
| 17 | 
            +
                network?: providers.Networkish;
         | 
| 18 | 
            +
            };
         | 
| 19 | 
            +
            /** @group Ethereum Plugin */
         | 
| 20 | 
            +
            export type Token = {
         | 
| 21 | 
            +
                chainId: number;
         | 
| 22 | 
            +
                address: string;
         | 
| 23 | 
            +
                name: string;
         | 
| 24 | 
            +
                symbol: string;
         | 
| 25 | 
            +
                decimals: number;
         | 
| 26 | 
            +
                logoURI: string;
         | 
| 27 | 
            +
                extensions: any;
         | 
| 28 | 
            +
            };
         | 
| 29 | 
            +
            /** @group Ethereum Plugin */
         | 
| 30 | 
            +
            export type TokenList = Token[];
         | 
| 31 | 
            +
            /** @group Ethereum Plugin */
         | 
| 32 | 
            +
            export type EthereumPlugin = Plugin<'Ethereum', any, EthereumPluginMethods, 'id'>;
         | 
    
        package/package.json
    ADDED
    
    | @@ -0,0 +1,44 @@ | |
| 1 | 
            +
            {
         | 
| 2 | 
            +
              "name": "@learncard/ethereum-plugin",
         | 
| 3 | 
            +
              "version": "1.0.0",
         | 
| 4 | 
            +
              "description": "",
         | 
| 5 | 
            +
              "main": "./dist/index.js",
         | 
| 6 | 
            +
              "module": "./dist/ethereum-plugin.esm.js",
         | 
| 7 | 
            +
              "private": false,
         | 
| 8 | 
            +
              "files": [
         | 
| 9 | 
            +
                "dist"
         | 
| 10 | 
            +
              ],
         | 
| 11 | 
            +
              "author": "Learning Economy Foundation (www.learningeconomy.io)",
         | 
| 12 | 
            +
              "license": "MIT",
         | 
| 13 | 
            +
              "homepage": "https://github.com/WeLibraryOS/LearnCard#readme",
         | 
| 14 | 
            +
              "repository": {
         | 
| 15 | 
            +
                "type": "git",
         | 
| 16 | 
            +
                "url": "git+https://github.com/WeLibraryOS/LearnCard.git"
         | 
| 17 | 
            +
              },
         | 
| 18 | 
            +
              "bugs": {
         | 
| 19 | 
            +
                "url": "https://github.com/WeLibraryOS/LearnCard/issues"
         | 
| 20 | 
            +
              },
         | 
| 21 | 
            +
              "devDependencies": {
         | 
| 22 | 
            +
                "@types/jest": "^29.2.2",
         | 
| 23 | 
            +
                "@types/node": "^17.0.31",
         | 
| 24 | 
            +
                "aqu": "0.4.3",
         | 
| 25 | 
            +
                "esbuild": "^0.14.38",
         | 
| 26 | 
            +
                "esbuild-jest": "^0.5.0",
         | 
| 27 | 
            +
                "esbuild-plugin-copy": "^1.3.0",
         | 
| 28 | 
            +
                "jest": "^29.3.0",
         | 
| 29 | 
            +
                "shx": "^0.3.4",
         | 
| 30 | 
            +
                "ts-jest": "^29.0.3"
         | 
| 31 | 
            +
              },
         | 
| 32 | 
            +
              "types": "./dist/index.d.ts",
         | 
| 33 | 
            +
              "dependencies": {
         | 
| 34 | 
            +
                "@uniswap/default-token-list": "^4.1.0",
         | 
| 35 | 
            +
                "ethers": "^5.6.9",
         | 
| 36 | 
            +
                "@learncard/core": "9.0.0"
         | 
| 37 | 
            +
              },
         | 
| 38 | 
            +
              "scripts": {
         | 
| 39 | 
            +
                "build": "node ./scripts/build.mjs && shx cp ./scripts/mixedEntypoint.js ./dist/index.js && tsc --p tsconfig.json",
         | 
| 40 | 
            +
                "test": "jest --passWithNoTests",
         | 
| 41 | 
            +
                "test:watch": "jest --watch",
         | 
| 42 | 
            +
                "test:coverage": "jest --silent --ci --coverage --coverageReporters=\"text\" --coverageReporters=\"text-summary\""
         | 
| 43 | 
            +
              }
         | 
| 44 | 
            +
            }
         |