-
Notifications
You must be signed in to change notification settings - Fork 5
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 #170 from logion-network/feature/multiversx
Support for MultiversX addresses, tokens and signatures.
- Loading branch information
Showing
16 changed files
with
474 additions
and
36 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
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
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,9 @@ | ||
/test/** | ||
/integration/** | ||
/src/** | ||
/scripts/** | ||
docker-compose.yml | ||
front_config.js | ||
front_web*.conf | ||
jasmine*.json | ||
tsconfig*.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,15 @@ | ||
{ | ||
"spec_dir": "test", | ||
"spec_files": [ | ||
"**/*.spec.ts" | ||
], | ||
"helpers": [ | ||
"typescript.js" | ||
], | ||
"stopSpecOnExpectationFailure": false, | ||
"reporters": [ | ||
{ | ||
"name": "jasmine-spec-reporter#SpecReporter" | ||
} | ||
] | ||
} |
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,52 @@ | ||
{ | ||
"name": "@logion/multiversx", | ||
"version": "0.1.0-4", | ||
"description": "logion SDK for MultiversX", | ||
"main": "dist/index.js", | ||
"packageManager": "yarn@3.2.0", | ||
"type": "module", | ||
"scripts": { | ||
"build": "yarn lint && tsc", | ||
"lint": "yarn eslint src/**", | ||
"test": "echo 'Nothing to test for the moment'" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/logion-network/logion-api.git", | ||
"directory": "packages/multiversx" | ||
}, | ||
"keywords": [ | ||
"logion" | ||
], | ||
"author": "Logion Team", | ||
"license": "Apache-2.0", | ||
"dependencies": { | ||
"@logion/client": "workspace:^", | ||
"@multiversx/sdk-core": "^12.4.3", | ||
"@multiversx/sdk-extension-provider": "^2.0.7" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/logion-network/logion-api/issues" | ||
}, | ||
"homepage": "https://github.com/logion-network/logion-api/packages/extension#readme", | ||
"devDependencies": { | ||
"@tsconfig/node18": "^1.0.1", | ||
"@types/node": "^18.6.1", | ||
"@typescript-eslint/eslint-plugin": "latest", | ||
"@typescript-eslint/parser": "latest", | ||
"eslint": "^8.20.0", | ||
"jasmine": "^4.3.0", | ||
"jasmine-spec-reporter": "^7.0.0", | ||
"moq.ts": "^9.0.2", | ||
"ts-node": "^10.9.1", | ||
"typescript": "^4.7.4" | ||
}, | ||
"engines": { | ||
"node": ">=16" | ||
}, | ||
"stableVersion": "0.1.0", | ||
"typedoc": { | ||
"entryPoint": "./src/index.ts", | ||
"displayName": "MultiversX" | ||
} | ||
} |
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,36 @@ | ||
import { BaseSigner, SignAndSendFunction, TypedSignature } from "@logion/client"; | ||
import { ValidAccountId } from "@logion/node-api"; | ||
import { SignableMessage } from "@multiversx/sdk-core"; | ||
import { ExtensionProvider } from "@multiversx/sdk-extension-provider"; | ||
|
||
export class MultiversxSigner extends BaseSigner { | ||
|
||
constructor() { | ||
super(); | ||
this.provider = ExtensionProvider.getInstance(); | ||
} | ||
|
||
private readonly provider: ExtensionProvider; | ||
|
||
async login(): Promise<string> { | ||
if (await this.provider.init()) { | ||
return await this.provider.login(); | ||
} else { | ||
throw new Error("No MultiversX account available"); | ||
} | ||
} | ||
|
||
async signToHex(_signerId: ValidAccountId, message: string): Promise<TypedSignature> { | ||
const signableMessage = new SignableMessage({ | ||
message: Buffer.from(message.substring(2), "hex") | ||
}); | ||
const signedMessage = await this.provider.signMessage(signableMessage); | ||
const signature = '0x' + signedMessage.getSignature().toString('hex'); | ||
return { signature, type: "MULTIVERSX" } | ||
} | ||
|
||
buildSignAndSendFunction(): Promise<SignAndSendFunction> { | ||
throw new Error("Cannot sign and send extrinsics with MultiversX signer"); | ||
} | ||
|
||
} |
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 @@ | ||
export * from './MultiversxSigner.js'; |
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 @@ | ||
{ | ||
"extends": "../../tsconfig.json", | ||
"compilerOptions": { | ||
"outDir": "./dist" | ||
}, | ||
"include": [ | ||
"./src/**/*" | ||
] | ||
} |
Oops, something went wrong.