-
Notifications
You must be signed in to change notification settings - Fork 333
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8163 from LedgerHQ/support/coin-stacks-module
LIVE-13681 chore: move stacks to its own module
- Loading branch information
Showing
64 changed files
with
984 additions
and
616 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,7 @@ | ||
--- | ||
"@ledgerhq/coin-stacks": patch | ||
"live-mobile": patch | ||
"@ledgerhq/live-common": patch | ||
--- | ||
|
||
support: move stacks to its own coin module |
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,20 @@ | ||
module.exports = { | ||
env: { | ||
browser: true, | ||
es6: true, | ||
}, | ||
overrides: [ | ||
{ | ||
files: ["src/**/*.test.{ts,tsx}"], | ||
env: { | ||
"jest/globals": true, | ||
}, | ||
plugins: ["jest"], | ||
}, | ||
], | ||
rules: { | ||
"no-console": ["error", { allow: ["warn", "error"] }], | ||
"@typescript-eslint/no-empty-function": "off", | ||
"@typescript-eslint/no-explicit-any": "warn", | ||
}, | ||
}; |
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,31 @@ | ||
{ | ||
"entry": [ | ||
"src/api/index.ts", | ||
"src/bridge/index.ts", | ||
"src/bridge/deviceTransactionConfig.ts", | ||
"src/datasets/dataset-1.ts", | ||
"src/signer/index.ts", | ||
"src/test/index.ts", | ||
"src/index.ts" | ||
], | ||
"ignorePatterns": [ | ||
"**/node_modules/**", | ||
"**/*.fixture.ts", | ||
"**/*.mock.ts", | ||
"**/*.test.{js,jsx,ts,tsx}" | ||
], | ||
"ignoreUnresolved": [ | ||
"jest-get-type", | ||
"jest-matcher-utils", | ||
"jest-message-util" | ||
], | ||
"ignoreUnimported": [ | ||
"src/network/index.ts", | ||
"src/signer/signMessage.ts" | ||
], | ||
"ignoreUnused": [ | ||
"@ledgerhq/types-cryptoassets", | ||
"ripple-address-codec", | ||
"ripple-binary-codec" | ||
] | ||
} |
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,8 @@ | ||
/** @type {import('ts-jest/dist/types').JestConfigWithTsJest} */ | ||
module.exports = { | ||
collectCoverageFrom: ["src/**/*.ts"], | ||
coverageDirectory: "coverage", | ||
preset: "ts-jest", | ||
testEnvironment: "node", | ||
testPathIgnorePatterns: ["lib/", "lib-es/", ".integration.test.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,136 @@ | ||
{ | ||
"name": "@ledgerhq/coin-stacks", | ||
"version": "0.1.0", | ||
"description": "Ledger Stacks Coin integration", | ||
"keywords": [ | ||
"Ledger", | ||
"LedgerWallet", | ||
"stacks", | ||
"stx", | ||
"Bitcoin layer2", | ||
"Hardware Wallet" | ||
], | ||
"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-stacks", | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"typesVersions": { | ||
"*": { | ||
"lib/*": [ | ||
"lib/*" | ||
], | ||
"lib-es/*": [ | ||
"lib-es/*" | ||
], | ||
"deviceTransactionConfig": [ | ||
"lib/bridge/deviceTransactionConfig" | ||
], | ||
"specs": [ | ||
"lib/test/bot-specs" | ||
], | ||
"transaction": [ | ||
"lib/bridge/transaction" | ||
], | ||
"*": [ | ||
"lib/*" | ||
] | ||
} | ||
}, | ||
"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" | ||
}, | ||
"./signer": { | ||
"require": "./lib/signer/index.js", | ||
"default": "./lib-es/signer/index.js" | ||
}, | ||
"./hw-signMessage": { | ||
"require": "./lib/signer/signMessage.js", | ||
"default": "./lib-es/signer/signMessage.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/devices": "workspace:*", | ||
"@ledgerhq/errors": "workspace:^", | ||
"@ledgerhq/live-env": "workspace:^", | ||
"@ledgerhq/live-network": "workspace:^", | ||
"@ledgerhq/logs": "workspace:^", | ||
"@ledgerhq/types-cryptoassets": "workspace:^", | ||
"@ledgerhq/types-live": "workspace:^", | ||
"axios": "1.7.7", | ||
"bignumber.js": "^9.1.2", | ||
"c32check": "1.1.3", | ||
"invariant": "^2.2.4", | ||
"lodash": "^4.17.21", | ||
"ripple-address-codec": "^5.0.0", | ||
"ripple-binary-codec": "^1.3.0", | ||
"rxjs": "^7.8.1", | ||
"@stacks/network": "6.10.0", | ||
"@stacks/transactions": "6.11.0", | ||
"@zondax/ledger-stacks": "^1.0.2" | ||
}, | ||
"devDependencies": { | ||
"@faker-js/faker": "^8.4.1", | ||
"@types/invariant": "^2.2.37", | ||
"@types/jest": "^29.5.12", | ||
"@types/lodash": "^4.14.191", | ||
"dotenv": "^16.4.5", | ||
"expect": "^27.4.6", | ||
"jest": "^29.7.0", | ||
"ripple-keypairs": "^2.0.0", | ||
"ts-jest": "^29.1.1", | ||
"typescript": "^5.4.5" | ||
}, | ||
"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-stacks.json", | ||
"prewatch": "pnpm build", | ||
"watch": "tsc --watch", | ||
"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", | ||
"test-integ": "DOTENV_CONFIG_PATH=.env.integ.test jest --config=jest.integ.config.js", | ||
"typecheck": "tsc --noEmit", | ||
"unimported": "unimported" | ||
} | ||
} |
10 changes: 5 additions & 5 deletions
10
...e-common/src/families/stacks/broadcast.ts → ...dules/coin-stacks/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
8 changes: 4 additions & 4 deletions
8
...milies/stacks/buildOptimisticOperation.ts → ...ks/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
4 changes: 2 additions & 2 deletions
4
.../src/families/stacks/createTransaction.ts → ...in-stacks/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
14 changes: 7 additions & 7 deletions
14
...c/families/stacks/estimateMaxSpendable.ts → ...stacks/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,64 @@ | ||
import { | ||
makeAccountBridgeReceive, | ||
makeScanAccounts, | ||
makeSync, | ||
} from "@ledgerhq/coin-framework/bridge/jsHelpers"; | ||
import resolver from "../signer/index"; | ||
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 { defaultUpdateTransaction } from "@ledgerhq/coin-framework/bridge/jsHelpers"; | ||
import type { Transaction, TransactionStatus, StacksSigner } from "../types"; | ||
import { getTransactionStatus } from "./getTransactionStatus"; | ||
import { estimateMaxSpendable } from "./estimateMaxSpendable"; | ||
import { prepareTransaction } from "./prepareTransaction"; | ||
import { createTransaction } from "./createTransaction"; | ||
import { getAccountShape } from "./synchronization"; | ||
import { buildSignOperation } from "./signOperation"; | ||
import { broadcast } from "./broadcast"; | ||
|
||
function buildCurrencyBridge(signerContext: SignerContext<StacksSigner>): 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<StacksSigner>, | ||
): AccountBridge<Transaction, Account, TransactionStatus> { | ||
const getAddress = resolver(signerContext); | ||
const receive = makeAccountBridgeReceive(getAddressWrapper(getAddress)); | ||
|
||
const signOperation = buildSignOperation(signerContext); | ||
|
||
return { | ||
estimateMaxSpendable, | ||
createTransaction, | ||
updateTransaction: defaultUpdateTransaction, | ||
getTransactionStatus, | ||
prepareTransaction, | ||
sync, | ||
receive, | ||
signOperation, | ||
broadcast, | ||
}; | ||
} | ||
|
||
export function createBridges(signerContext: SignerContext<StacksSigner>) { | ||
return { | ||
currencyBridge: buildCurrencyBridge(signerContext), | ||
accountBridge: buildAccountBridge(signerContext), | ||
}; | ||
} | ||
export { prepareTransaction, estimateMaxSpendable }; |
Oops, something went wrong.