-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added helper methods to allow dapps to create rpc requests
- Loading branch information
1 parent
b2176d0
commit 7ad95f7
Showing
5 changed files
with
70 additions
and
14 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from './sendNanoContractTx'; | ||
export * from './signWithAddress'; |
33 changes: 33 additions & 0 deletions
33
packages/hathor-rpc-handler/src/rpcRequest/sendNanoContractTx.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,33 @@ | ||
/** | ||
* Copyright (c) Hathor Labs and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
import type { NanoContractAction } from '@hathor/wallet-lib/lib/nano_contracts/types'; | ||
import { | ||
RpcMethods, | ||
SendNanoContractRpcRequest, | ||
} from '../types'; | ||
|
||
export function sendNanoContractTxRpcRequest( | ||
method: string, | ||
blueprintId: string, | ||
actions: NanoContractAction[], | ||
args: unknown[], | ||
pushTx: boolean, | ||
ncId: string | null, | ||
): SendNanoContractRpcRequest { | ||
return { | ||
method: RpcMethods.SendNanoContractTx, | ||
params: { | ||
method, | ||
blueprint_id: blueprintId, | ||
actions, | ||
args, | ||
push_tx: pushTx, | ||
nc_id: ncId, | ||
} | ||
}; | ||
} |
26 changes: 26 additions & 0 deletions
26
packages/hathor-rpc-handler/src/rpcRequest/signWithAddress.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,26 @@ | ||
/** | ||
* Copyright (c) Hathor Labs and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
import { | ||
RpcMethods, | ||
SignWithAddressRpcRequest, | ||
} from '../types'; | ||
|
||
export function signWithAddressRpcRequest( | ||
network: string, | ||
message: string, | ||
addressIndex: number, | ||
): SignWithAddressRpcRequest { | ||
return { | ||
method: RpcMethods.SignWithAddress, | ||
params: { | ||
network, | ||
message, | ||
addressIndex, | ||
} | ||
}; | ||
} |
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