-
Notifications
You must be signed in to change notification settings - Fork 357
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* coin modul hedera --------- Co-authored-by: qperrot <[email protected]>
- Loading branch information
Showing
61 changed files
with
1,181 additions
and
339 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,8 @@ | ||
--- | ||
"@ledgerhq/coin-hedera": minor | ||
"@ledgerhq/hw-app-hedera": patch | ||
"@actions/turbo-affected": patch | ||
"@ledgerhq/live-common": patch | ||
--- | ||
|
||
Creation of coin-hedera package |
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,33 @@ | ||
{ | ||
"entry": [ | ||
"src/account.ts", | ||
"src/bridge/index.ts", | ||
"src/test/cli.ts", | ||
"src/deviceTransactionConfig.ts", | ||
"src/errors.ts", | ||
"src/hw-getAddress.ts", | ||
"src/specs.ts", | ||
"src/transaction.ts" | ||
], | ||
"ignorePatterns": [ | ||
"**/node_modules/**", | ||
"**/*.fixture.ts", | ||
"**/*.mock.ts", | ||
"**/*.test.{js,jsx,ts,tsx}" | ||
], | ||
"ignoreUnresolved": [], | ||
"ignoreUnimported": [ | ||
"src/index.ts", | ||
"src/test/bot-specs.ts", | ||
"src/test/bridgeDatasetTest.ts", | ||
"src/test/cli.ts", | ||
"src/test/index.ts", | ||
"src/test/speculos-deviceActions.ts" | ||
], | ||
"ignoreUnused": [ | ||
"@ledgerhq/devices", | ||
"expect", | ||
"lodash", | ||
"rxjs" | ||
] | ||
} |
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/", ".integration.test.ts"], | ||
modulePathIgnorePatterns: ["__tests__/fixtures"], | ||
}; |
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,112 @@ | ||
{ | ||
"name": "@ledgerhq/coin-hedera", | ||
"version": "1.0.0", | ||
"description": "Ledger Hedera Coin integration", | ||
"keywords": [ | ||
"Ledger", | ||
"LedgerWallet", | ||
"hbar", | ||
"Hedera", | ||
"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-hedera", | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"typesVersions": { | ||
"*": { | ||
"lib/*": [ | ||
"lib/*" | ||
], | ||
"lib-es/*": [ | ||
"lib-es/*" | ||
], | ||
"specs": [ | ||
"lib/test/bot-specs" | ||
], | ||
"*": [ | ||
"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/deviceTransactionConfig.js", | ||
"default": "./lib-es/deviceTransactionConfig.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/transaction.js", | ||
"default": "./lib-es/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/types-live": "workspace:^", | ||
"@ledgerhq/live-countervalues": "workspace:^", | ||
"@hashgraph/sdk": "2.14.2", | ||
"expect": "^27.4.6", | ||
"invariant": "^2.2.2", | ||
"lodash": "^4.17.21", | ||
"bignumber.js": "^9.1.2", | ||
"rxjs": "^7.8.1" | ||
}, | ||
"devDependencies": { | ||
"@types/invariant": "^2.2.2", | ||
"@types/jest": "^29.5.10", | ||
"@types/lodash": "^4.14.191", | ||
"jest": "^29.7.0", | ||
"ts-jest": "^29.1.1" | ||
}, | ||
"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-hedera.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", | ||
"unimported": "unimported" | ||
} | ||
} |
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
6 changes: 3 additions & 3 deletions
6
...e-common/src/families/hedera/broadcast.ts → ...dules/coin-hedera/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
4 changes: 2 additions & 2 deletions
4
...milies/hedera/buildOptimisticOperation.ts → ...ra/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/hedera/createTransaction.ts → ...in-hedera/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
4 changes: 2 additions & 2 deletions
4
...c/families/hedera/estimateMaxSpendable.ts → ...hedera/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,60 @@ | ||
import { 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, HederaSigner } from "../types"; | ||
import { getTransactionStatus } from "./getTransactionStatus"; | ||
import { estimateMaxSpendable } from "./estimateMaxSpendable"; | ||
import { prepareTransaction } from "./prepareTransaction"; | ||
import { createTransaction } from "./createTransaction"; | ||
import { getAccountShape, buildIterateResult } from "./synchronisation"; | ||
import { buildSignOperation } from "./signOperation"; | ||
import { broadcast } from "./broadcast"; | ||
import { receive } from "./receive"; | ||
|
||
function buildCurrencyBridge(signerContext: SignerContext<HederaSigner>): CurrencyBridge { | ||
const getAddress = resolver(signerContext); | ||
|
||
const scanAccounts = makeScanAccounts({ | ||
getAccountShape, | ||
buildIterateResult, | ||
getAddressFn: getAddressWrapper(getAddress), | ||
}); | ||
|
||
return { | ||
preload: () => Promise.resolve({}), | ||
hydrate: () => {}, | ||
scanAccounts, | ||
}; | ||
} | ||
|
||
const sync = makeSync({ getAccountShape }); | ||
|
||
function buildAccountBridge( | ||
signerContext: SignerContext<HederaSigner>, | ||
): AccountBridge<Transaction, Account, TransactionStatus> { | ||
const getAddress = resolver(signerContext); | ||
|
||
const signOperation = buildSignOperation(signerContext); | ||
|
||
return { | ||
estimateMaxSpendable, | ||
createTransaction, | ||
updateTransaction: defaultUpdateTransaction, | ||
getTransactionStatus, | ||
prepareTransaction, | ||
sync, | ||
receive: receive(getAddressWrapper(getAddress)), | ||
signOperation, | ||
broadcast, | ||
}; | ||
} | ||
|
||
export function createBridges(signerContext: SignerContext<HederaSigner>) { | ||
return { | ||
currencyBridge: buildCurrencyBridge(signerContext), | ||
accountBridge: buildAccountBridge(signerContext), | ||
}; | ||
} |
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
2 changes: 1 addition & 1 deletion
2
...src/families/hedera/prepareTransaction.ts → ...n-hedera/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.