-
Notifications
You must be signed in to change notification settings - Fork 10
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
1 parent
83ebc85
commit ad521c3
Showing
35 changed files
with
2,078 additions
and
52 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,4 +5,5 @@ use ( | |
./hostd | ||
./renterd | ||
./walletd | ||
./sdk | ||
) |
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 @@ | ||
*.wasm |
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 |
---|---|---|
@@ -1,2 +1,2 @@ | ||
export * from './types' | ||
export * from './transport' | ||
export * from './wasm' |
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
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.
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,10 @@ | ||
declare module '*.wasm' { | ||
const func: ( | ||
imports: WebAssembly.Imports | ||
) => Promise<WebAssembly.WebAssemblyInstantiatedSource> | ||
export default func | ||
} | ||
|
||
interface Window { | ||
Go: typeof Go | ||
} |
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,24 @@ | ||
import './utils/wasm_exec_tinygo' | ||
import wasm from './resources/sdk.wasm' | ||
import { SDK } from './types' | ||
|
||
export function getSDK() { | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
return (global as any).sdk as SDK | ||
} | ||
|
||
export async function initSDK(): Promise<{ sdk?: SDK; error?: string }> { | ||
try { | ||
const go = new window.Go() | ||
const source = await wasm(go.importObject) | ||
await go.run(source.instance) | ||
return { | ||
sdk: getSDK(), | ||
} | ||
} catch (e) { | ||
console.log(e) | ||
return { | ||
error: (e as Error).message, | ||
} | ||
} | ||
} |
Empty file.
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,68 @@ | ||
import { | ||
RPCReadSectorRequest, | ||
RPCReadSectorResponse, | ||
RPCSettingsRequest, | ||
RPCSettingsResponse, | ||
RPCWriteSectorRequest, | ||
RPCWriteSectorResponse, | ||
} from '../types' | ||
|
||
export type SDK = { | ||
rhp: { | ||
// settings | ||
encodeSettingsRequest: () => { | ||
rpc?: Uint8Array | ||
error?: string | ||
} | ||
decodeSettingsRequest: () => { | ||
data?: RPCSettingsRequest | ||
error?: string | ||
} | ||
encodeSettingsResponse: () => { | ||
rpc?: Uint8Array | ||
error?: string | ||
} | ||
decodeSettingsResponse: () => { | ||
data?: RPCSettingsResponse | ||
error?: string | ||
} | ||
// read sector | ||
encodeReadSectorRequest: () => { | ||
rpc?: Uint8Array | ||
error?: string | ||
} | ||
decodeReadSectorRequest: () => { | ||
data?: RPCReadSectorRequest | ||
error?: string | ||
} | ||
encodeReadSectorResponse: () => { | ||
rpc?: Uint8Array | ||
error?: string | ||
} | ||
decodeReadSectorResponse: () => { | ||
data?: RPCReadSectorResponse | ||
error?: string | ||
} | ||
// read sector | ||
encodeWriteSectorRequest: () => { | ||
rpc?: Uint8Array | ||
error?: string | ||
} | ||
decodeWriteSectorRequest: () => { | ||
data?: RPCWriteSectorRequest | ||
error?: string | ||
} | ||
encodeWriteSectorResponse: () => { | ||
rpc?: Uint8Array | ||
error?: string | ||
} | ||
decodeWriteSectorResponse: () => { | ||
data?: RPCWriteSectorResponse | ||
error?: string | ||
} | ||
} | ||
generateAccountID: () => { | ||
accountID?: string | ||
error?: string | ||
} | ||
} |
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,10 @@ | ||
declare class Go { | ||
constructor() | ||
argv: string[] | ||
env: { [envKey: string]: string } | ||
exit: (code: number) => void | ||
importObject: WebAssembly.Imports | ||
exited: boolean | ||
mem: DataView | ||
run(instance: WebAssembly.Instance): Promise<void> | ||
} |
Oops, something went wrong.