-
Notifications
You must be signed in to change notification settings - Fork 362
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
66 changed files
with
994 additions
and
697 deletions.
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,6 @@ | ||
--- | ||
"@ledgerhq/coin-casper": minor | ||
"@ledgerhq/live-common": minor | ||
--- | ||
|
||
casper coin modularization |
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,46 @@ | ||
{ | ||
"entry": [ | ||
"src/api/api.ts", | ||
"src/api/index.ts", | ||
"src/bridge/bridgeHelpers/accountShape.ts", | ||
"src/bridge/bridgeHelpers/addresses.ts", | ||
"src/bridge/bridgeHelpers/fee.ts", | ||
"src/bridge/bridgeHelpers/transferId.ts", | ||
"src/bridge/bridgeHelpers/txn.ts", | ||
"src/bridge/broadcast.ts", | ||
"src/bridge/buildOptimisticOperation.ts", | ||
"src/bridge/createTransaction.ts", | ||
"src/bridge/deviceTransactionConfig.ts", | ||
"src/bridge/estimateMaxSpendable.ts", | ||
"src/bridge/getTransactionStatus.ts", | ||
"src/bridge/index.ts", | ||
"src/bridge/prepareTransaction.ts", | ||
"src/bridge/signOperation.ts", | ||
"src/bridge/transaction.ts", | ||
"src/common-logic/index.ts", | ||
"src/common-logic/utils.ts", | ||
"src/consts.ts", | ||
"src/errors.ts", | ||
"src/hw-signMessage.ts", | ||
"src/signer/getAddress.ts", | ||
"src/signer/index.ts", | ||
"src/test/bot-specs.ts", | ||
"src/test/bridgeDatasetTest.ts", | ||
"src/test/cli.ts", | ||
"src/test/index.ts", | ||
"src/test/speculos-deviceActions.ts", | ||
"src/types/common.ts", | ||
"src/types/index.ts", | ||
"src/types/signer.ts", | ||
"src/consts.ts", | ||
"src/errors.ts", | ||
"src/hw-signMessage.ts" | ||
], | ||
"ignoreUnresolved": [ | ||
"follow-redirects", | ||
"form-data", | ||
"proxy-from-env" | ||
], | ||
"ignoreUnused": [], | ||
"ignoreUnimported": [] | ||
} |
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,9 @@ | ||
/** @type {import('ts-jest/dist/types').JestConfigWithTsJest} */ | ||
module.exports = { | ||
collectCoverageFrom: ["src/**/*.ts"], | ||
coverageDirectory: "coverage", | ||
preset: "ts-jest", | ||
testEnvironment: "node", | ||
testPathIgnorePatterns: ["lib/", "lib-es/"], | ||
passWithNoTests: true, | ||
}; |
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,126 @@ | ||
{ | ||
"name": "@ledgerhq/coin-casper", | ||
"version": "1.3.2", | ||
"description": "Ledger Casper integration", | ||
"keywords": [ | ||
"Ledger", | ||
"LedgerWallet", | ||
"Casper", | ||
"CSPR" | ||
], | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/LedgerHQ/ledger-live.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/LedgerHQ/ledger-live/issues" | ||
}, | ||
"homepage": "https://github.com/LedgerHQ/ledger-live/tree/develop/libs/coin-modules/coin-casper", | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"typesVersions": { | ||
"*": { | ||
"lib/*": [ | ||
"lib/*" | ||
], | ||
"lib-es/*": [ | ||
"lib-es/*" | ||
], | ||
"specs": [ | ||
"lib/test/bot-specs" | ||
], | ||
"*": [ | ||
"lib/*", | ||
"lib/api/*", | ||
"lib/bridge/*", | ||
"lib/common-logic/*", | ||
"lib/signer/*", | ||
"lib/test/*", | ||
"lib/types/*" | ||
] | ||
} | ||
}, | ||
"exports": { | ||
"./lib/*": "./lib/*.js", | ||
"./lib-es/*": "./lib-es/*.js", | ||
"./api": { | ||
"require": "./lib/api/index.js", | ||
"default": "./lib-es/api/index.js" | ||
}, | ||
"./deviceTransactionConfig": { | ||
"require": "./lib/bridge/deviceTransactionConfig.js", | ||
"default": "./lib-es/bridge/deviceTransactionConfig.js" | ||
}, | ||
"./logic": { | ||
"require": "./lib/common-logic/index.js", | ||
"default": "./lib-es/common-logic/index.js" | ||
}, | ||
"./signer": { | ||
"require": "./lib/signer/index.js", | ||
"default": "./lib-es/signer/index.js" | ||
}, | ||
"./specs": { | ||
"require": "./lib/test/bot-specs.js", | ||
"default": "./lib-es/test/bot-specs.js" | ||
}, | ||
"./transaction": { | ||
"require": "./lib/bridge/transaction.js", | ||
"default": "./lib-es/bridge/transaction.js" | ||
}, | ||
"./types": { | ||
"require": "./lib/types/index.js", | ||
"default": "./lib-es/types/index.js" | ||
}, | ||
"./*": { | ||
"require": "./lib/*.js", | ||
"default": "./lib-es/*.js" | ||
}, | ||
".": { | ||
"require": "./lib/index.js", | ||
"default": "./lib-es/index.js" | ||
}, | ||
"./package.json": "./package.json" | ||
}, | ||
"license": "Apache-2.0", | ||
"dependencies": { | ||
"@ledgerhq/coin-framework": "workspace:^", | ||
"@ledgerhq/cryptoassets": "workspace:^", | ||
"@ledgerhq/types-cryptoassets": "workspace:^", | ||
"@ledgerhq/devices": "workspace:*", | ||
"@ledgerhq/errors": "workspace:^", | ||
"@ledgerhq/live-env": "workspace:^", | ||
"@ledgerhq/live-network": "workspace:^", | ||
"@ledgerhq/logs": "workspace:^", | ||
"@ledgerhq/types-live": "workspace:^", | ||
"bignumber.js": "^9.1.2", | ||
"invariant": "^2.2.2", | ||
"lodash": "^4.17.21", | ||
"casper-js-sdk": "^2.15.2", | ||
"blakejs": "^1.2.1", | ||
"rxjs": "^7.8.1", | ||
"expect": "^27.4.6" | ||
}, | ||
"devDependencies": { | ||
"@types/invariant": "^2.2.2", | ||
"@types/jest": "^29.5.10", | ||
"@types/lodash": "^4.14.191", | ||
"@types/semver": "^7.5.8", | ||
"jest": "^29.7.0", | ||
"ts-jest": "^29.1.1", | ||
"axios": "1.7.7" | ||
}, | ||
"scripts": { | ||
"clean": "rimraf lib lib-es", | ||
"build": "tsc && tsc -m ES6 --outDir lib-es", | ||
"coverage": "jest --coverage --testPathIgnorePatterns='/bridge.integration.test.ts|node_modules|lib-es|lib/' --passWithNoTests && mv coverage/coverage-final.json coverage/coverage-casper.json", | ||
"prewatch": "pnpm build", | ||
"watch": "tsc --watch", | ||
"watch:es": "tsc --watch -m ES6 --outDir lib-es", | ||
"doc": "documentation readme src/** --section=API --pe ts --re ts --re d.ts", | ||
"lint": "eslint ./src --no-error-on-unmatched-pattern --ext .ts,.tsx --cache", | ||
"lint:fix": "pnpm lint --fix", | ||
"test": "jest", | ||
"unimported": "unimported" | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
3 changes: 1 addition & 2 deletions
3
...sper/bridge/bridgeHelpers/accountShape.ts → .../src/bridge/bridgeHelpers/accountShape.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
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
4 changes: 2 additions & 2 deletions
4
...e-common/src/families/casper/broadcast.ts → ...dules/coin-casper/src/bridge/broadcast.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
6 changes: 3 additions & 3 deletions
6
...milies/casper/buildOptimisticOperation.ts → ...er/src/bridge/buildOptimisticOperation.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
2 changes: 1 addition & 1 deletion
2
.../src/families/casper/createTransaction.ts → ...in-casper/src/bridge/createTransaction.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
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
4 changes: 2 additions & 2 deletions
4
...c/families/casper/estimateMaxSpendable.ts → ...casper/src/bridge/estimateMaxSpendable.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
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
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,65 @@ | ||
import { | ||
getSerializedAddressParameters, | ||
makeAccountBridgeReceive, | ||
makeScanAccounts, | ||
makeSync, | ||
updateTransaction, | ||
} from "@ledgerhq/coin-framework/bridge/jsHelpers"; | ||
import resolver from "../signer"; | ||
import getAddressWrapper from "@ledgerhq/coin-framework/bridge/getAddressWrapper"; | ||
import { SignerContext } from "@ledgerhq/coin-framework/signer"; | ||
import type { Account, AccountBridge, CurrencyBridge } from "@ledgerhq/types-live"; | ||
import type { Transaction, TransactionStatus, CasperSigner } from "../types"; | ||
import { getTransactionStatus } from "./getTransactionStatus"; | ||
import { estimateMaxSpendable } from "./estimateMaxSpendable"; | ||
import { prepareTransaction } from "./prepareTransaction"; | ||
import { createTransaction } from "./createTransaction"; | ||
import { getAccountShape } from "./bridgeHelpers/accountShape"; | ||
import { buildSignOperation } from "./signOperation"; | ||
import { broadcast } from "./broadcast"; | ||
|
||
function buildCurrencyBridge(signerContext: SignerContext<CasperSigner>): CurrencyBridge { | ||
const getAddress = resolver(signerContext); | ||
|
||
const scanAccounts = makeScanAccounts({ | ||
getAccountShape, | ||
getAddressFn: getAddressWrapper(getAddress), | ||
}); | ||
|
||
return { | ||
preload: () => Promise.resolve({}), | ||
hydrate: () => {}, | ||
scanAccounts, | ||
}; | ||
} | ||
|
||
const sync = makeSync({ getAccountShape }); | ||
|
||
function buildAccountBridge( | ||
signerContext: SignerContext<CasperSigner>, | ||
): AccountBridge<Transaction, Account, TransactionStatus> { | ||
const getAddress = resolver(signerContext); | ||
|
||
const receive = makeAccountBridgeReceive(getAddressWrapper(getAddress)); | ||
const signOperation = buildSignOperation(signerContext); | ||
|
||
return { | ||
estimateMaxSpendable, | ||
createTransaction, | ||
updateTransaction, | ||
getTransactionStatus, | ||
prepareTransaction, | ||
sync, | ||
receive, | ||
signOperation, | ||
broadcast, | ||
getSerializedAddressParameters, | ||
}; | ||
} | ||
|
||
export function createBridges(signerContext: SignerContext<CasperSigner>) { | ||
return { | ||
currencyBridge: buildCurrencyBridge(signerContext), | ||
accountBridge: buildAccountBridge(signerContext), | ||
}; | ||
} |
4 changes: 2 additions & 2 deletions
4
...src/families/casper/prepareTransaction.ts → ...n-casper/src/bridge/prepareTransaction.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
Oops, something went wrong.