Implement payments for app deployments #17
@ -5,7 +5,8 @@ import { Octokit } from 'octokit';
|
|||||||
import { inc as semverInc } from 'semver';
|
import { inc as semverInc } from 'semver';
|
||||||
import { DeepPartial } from 'typeorm';
|
import { DeepPartial } from 'typeorm';
|
||||||
|
|
||||||
import { Account, Registry as LaconicRegistry, getGasPrice, parseGasAndFees, IndexedTx } from '@cerc-io/registry-sdk';
|
import { Account, Registry as LaconicRegistry, getGasPrice, parseGasAndFees } from '@cerc-io/registry-sdk';
|
||||||
|
import { IndexedTx } from '@cosmjs/stargate';
|
||||||
|
|
||||||
import { RegistryConfig } from './config';
|
import { RegistryConfig } from './config';
|
||||||
import {
|
import {
|
||||||
|
@ -85,16 +85,16 @@ export const createResolvers = async (service: Service): Promise<any> => {
|
|||||||
return service.getAddress();
|
return service.getAddress();
|
||||||
},
|
},
|
||||||
|
|
||||||
// verifyTx: async (
|
verifyTx: async (
|
||||||
// _: any,
|
_: any,
|
||||||
// {
|
{
|
||||||
// txHash,
|
txHash,
|
||||||
// amount,
|
amount,
|
||||||
// senderAddress,
|
senderAddress,
|
||||||
// }: { txHash: string; amount: string; senderAddress: string },
|
}: { txHash: string; amount: string; senderAddress: string },
|
||||||
// ) => {
|
) => {
|
||||||
// return service.verifyTx(txHash, amount, senderAddress);
|
return service.verifyTx(txHash, amount, senderAddress);
|
||||||
// },
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
// TODO: Return error in GQL response
|
// TODO: Return error in GQL response
|
||||||
|
@ -30,10 +30,6 @@
|
|||||||
"@radix-ui/react-tabs": "^1.0.4",
|
"@radix-ui/react-tabs": "^1.0.4",
|
||||||
"@radix-ui/react-toast": "^1.1.5",
|
"@radix-ui/react-toast": "^1.1.5",
|
||||||
"@radix-ui/react-tooltip": "^1.0.7",
|
"@radix-ui/react-tooltip": "^1.0.7",
|
||||||
"@snowballtools/auth": "^0.2.0",
|
|
||||||
"@snowballtools/auth-lit": "^0.2.0",
|
|
||||||
"@snowballtools/js-sdk": "^0.1.1",
|
|
||||||
"@snowballtools/link-lit-alchemy-light": "^0.2.0",
|
|
||||||
"@snowballtools/material-tailwind-react-fork": "^2.1.10",
|
"@snowballtools/material-tailwind-react-fork": "^2.1.10",
|
||||||
"@snowballtools/smartwallet-alchemy-light": "^0.2.0",
|
"@snowballtools/smartwallet-alchemy-light": "^0.2.0",
|
||||||
"@snowballtools/types": "^0.2.0",
|
"@snowballtools/types": "^0.2.0",
|
||||||
|
@ -40,7 +40,7 @@ const deployment: Deployment = {
|
|||||||
deployerApiUrl: 'https://webapp-deployer-api.example.com',
|
deployerApiUrl: 'https://webapp-deployer-api.example.com',
|
||||||
deployerId: 'bafyreicrtgmkir4evvvysxdqxddf2ftdq2wrzuodgvwnxr4rmubi4obdfu',
|
deployerId: 'bafyreicrtgmkir4evvvysxdqxddf2ftdq2wrzuodgvwnxr4rmubi4obdfu',
|
||||||
deployerLrn: 'lrn://example/deployers/webapp-deployer-api.example.com',
|
deployerLrn: 'lrn://example/deployers/webapp-deployer-api.example.com',
|
||||||
minimumPayment: '1000units'
|
minimumPayment: '1000alnt'
|
||||||
},
|
},
|
||||||
status: DeploymentStatus.Ready,
|
status: DeploymentStatus.Ready,
|
||||||
createdBy: {
|
createdBy: {
|
||||||
|
@ -106,7 +106,7 @@ export const deployment0: Deployment = {
|
|||||||
deployerApiUrl: 'https://webapp-deployer-api.example.com',
|
deployerApiUrl: 'https://webapp-deployer-api.example.com',
|
||||||
deployerId: 'bafyreicrtgmkir4evvvysxdqxddf2ftdq2wrzuodgvwnxr4rmubi4obdfu',
|
deployerId: 'bafyreicrtgmkir4evvvysxdqxddf2ftdq2wrzuodgvwnxr4rmubi4obdfu',
|
||||||
deployerLrn: 'lrn://deployer.apps.snowballtools.com ',
|
deployerLrn: 'lrn://deployer.apps.snowballtools.com ',
|
||||||
minimumPayment: '1000units'
|
minimumPayment: '1000alnt'
|
||||||
},
|
},
|
||||||
applicationDeploymentRequestId:
|
applicationDeploymentRequestId:
|
||||||
'bafyreiaycvq6imoppnpwdve4smj6t6ql5svt5zl3x6rimu4qwyzgjorize',
|
'bafyreiaycvq6imoppnpwdve4smj6t6ql5svt5zl3x6rimu4qwyzgjorize',
|
||||||
@ -133,7 +133,7 @@ export const project: Project = {
|
|||||||
deployerApiUrl: 'https://webapp-deployer-api.example.com',
|
deployerApiUrl: 'https://webapp-deployer-api.example.com',
|
||||||
deployerId: 'bafyreicrtgmkir4evvvysxdqxddf2ftdq2wrzuodgvwnxr4rmubi4obdfu',
|
deployerId: 'bafyreicrtgmkir4evvvysxdqxddf2ftdq2wrzuodgvwnxr4rmubi4obdfu',
|
||||||
deployerLrn: 'lrn://deployer.apps.snowballtools.com ',
|
deployerLrn: 'lrn://deployer.apps.snowballtools.com ',
|
||||||
minimumPayment: '1000units'
|
minimumPayment: '1000alnt'
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
paymentAddress: '0x657868687686rb4787987br8497298r79284797487',
|
paymentAddress: '0x657868687686rb4787987br8497298r79284797487',
|
||||||
|
@ -1,48 +0,0 @@
|
|||||||
import { SiweMessage } from 'siwe';
|
|
||||||
import { PKPEthersWallet } from '@lit-protocol/pkp-ethers';
|
|
||||||
import { v4 as uuid } from 'uuid';
|
|
||||||
|
|
||||||
import { BASE_URL } from './constants';
|
|
||||||
|
|
||||||
const domain = window.location.host;
|
|
||||||
const origin = window.location.origin;
|
|
||||||
|
|
||||||
export async function signInWithEthereum(
|
|
||||||
chainId: number,
|
|
||||||
action: 'signup' | 'login',
|
|
||||||
wallet: PKPEthersWallet,
|
|
||||||
) {
|
|
||||||
const message = await createSiweMessage(
|
|
||||||
chainId,
|
|
||||||
await wallet.getAddress(),
|
|
||||||
'Sign in with Ethereum to the app.',
|
|
||||||
);
|
|
||||||
const signature = await wallet.signMessage(message);
|
|
||||||
|
|
||||||
const res = await fetch(`${BASE_URL}/auth/validate`, {
|
|
||||||
method: 'POST',
|
|
||||||
headers: {
|
|
||||||
'Content-Type': 'application/json',
|
|
||||||
},
|
|
||||||
body: JSON.stringify({ action, message, signature }),
|
|
||||||
credentials: 'include',
|
|
||||||
});
|
|
||||||
return (await res.json()) as { success: boolean; error?: string };
|
|
||||||
}
|
|
||||||
|
|
||||||
async function createSiweMessage(
|
|
||||||
chainId: number,
|
|
||||||
address: string,
|
|
||||||
statement: string,
|
|
||||||
) {
|
|
||||||
const message = new SiweMessage({
|
|
||||||
domain,
|
|
||||||
address,
|
|
||||||
statement,
|
|
||||||
uri: origin,
|
|
||||||
version: '1',
|
|
||||||
chainId,
|
|
||||||
nonce: uuid().replace(/[^a-z0-9]/g, ''),
|
|
||||||
});
|
|
||||||
return message.prepareMessage();
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user