-
Notifications
You must be signed in to change notification settings - Fork 195
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
99eed29
commit 494a1dd
Showing
6 changed files
with
107 additions
and
179 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,49 @@ | ||
import Provider from "."; | ||
import { RequestInvoiceArgs } from "."; | ||
|
||
export default class WebBTCProvider extends Provider { | ||
// TODO: return {version: "x.x.x", methods: [...]} | ||
getInfo() { | ||
if (!this.enabled) { | ||
throw new Error("Provider must be enabled before calling getInfo"); | ||
} | ||
return this.execute("getInfo"); | ||
} | ||
|
||
// TODO: only return signature: string | ||
signMessage(message: string) { | ||
if (!this.enabled) { | ||
throw new Error("Provider must be enabled before calling signMessage"); | ||
} | ||
|
||
return this.execute("signMessageOrPrompt", { message }); | ||
} | ||
|
||
// TODO: only return {paymentRequest: string} | ||
makeInvoice(args: string | number | RequestInvoiceArgs) { | ||
if (!this.enabled) { | ||
throw new Error("Provider must be enabled before calling makeInvoice"); | ||
} | ||
if (typeof args !== "object") { | ||
args = { amount: args }; | ||
} | ||
|
||
return this.execute("makeInvoice", args); | ||
} | ||
|
||
sendTransaction(address: string, amount: string) { | ||
if (!this.enabled) { | ||
throw new Error( | ||
"Provider must be enabled before calling sendTransaction" | ||
); | ||
} | ||
throw new Error("Alby does not support `sendTransaction`"); | ||
} | ||
|
||
getAddress(index: number, num: number, change: boolean) { | ||
if (!this.enabled) { | ||
throw new Error("Provider must be enabled before calling getAddress"); | ||
} | ||
throw new Error("Alby does not support `getAddress`"); | ||
} | ||
} |
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,50 @@ | ||
import Provider from "."; | ||
import { RequestInvoiceArgs } from "."; | ||
|
||
type KeysendArgs = { | ||
destination: string; | ||
customRecords?: Record<string, string>; | ||
amount: string | number; | ||
}; | ||
|
||
export default class WebLNProvider extends Provider { | ||
getInfo() { | ||
if (!this.enabled) { | ||
throw new Error("Provider must be enabled before calling getInfo"); | ||
} | ||
return this.execute("getInfo"); | ||
} | ||
|
||
lnurl(lnurlEncoded: string) { | ||
if (!this.enabled) { | ||
throw new Error("Provider must be enabled before calling lnurl"); | ||
} | ||
return this.execute("lnurl", { lnurlEncoded }); | ||
} | ||
|
||
keysend(args: KeysendArgs) { | ||
if (!this.enabled) { | ||
throw new Error("Provider must be enabled before calling keysend"); | ||
} | ||
return this.execute("keysendOrPrompt", args); | ||
} | ||
|
||
makeInvoice(args: string | number | RequestInvoiceArgs) { | ||
if (!this.enabled) { | ||
throw new Error("Provider must be enabled before calling makeInvoice"); | ||
} | ||
if (typeof args !== "object") { | ||
args = { amount: args }; | ||
} | ||
|
||
return this.execute("makeInvoice", args); | ||
} | ||
|
||
signMessage(message: string) { | ||
if (!this.enabled) { | ||
throw new Error("Provider must be enabled before calling signMessage"); | ||
} | ||
|
||
return this.execute("signMessageOrPrompt", { message }); | ||
} | ||
} |
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 was deleted.
Oops, something went wrong.