Skip to content

Commit

Permalink
updated federation types
Browse files Browse the repository at this point in the history
  • Loading branch information
paulfears committed Oct 22, 2024
1 parent db12e02 commit 49d7915
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 11 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "stellar-snap",
"version": "1.0.4",
"version": "1.0.5",
"description": "A non custodial Stellar Wallet for metamask",
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion site/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions site/src/routes/transactionBuilder/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ async function callMetaStellar(method, params){
const address = \`\${'${$dataPacket.currentAddress}'}\`
async function CreateTransaction(network, address){
const passpharase = network === 'testnet'? StellarSdk.Networks.TESTNET : StellarSdk.Networks.PUBLIC
const server = new StellarSdk.Horizon.Server(network === 'testnet'?'https://horizon-testnet.stellar.org':'https://horizon.stellar.org');
Expand Down Expand Up @@ -114,6 +115,7 @@ async function callMetaStellar(method, params){
CreateTransaction(network, address)
.then(
async (txnXDR) => {
await callMetaStellar('connect');
alert(
JSON.stringify(
await callMetaStellar('signAndSubmitTransaction',
Expand Down
2 changes: 1 addition & 1 deletion site/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5002,7 +5002,7 @@ stellar-sdk@^12.2.0:
urijs "^1.19.1"

"stellar-snap@file:..":
version "1.0.4"
version "1.0.5"
resolved "file:.."
dependencies:
"@metamask/snaps-sdk" "^6.7.0"
Expand Down
6 changes: 3 additions & 3 deletions snap.manifest.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"version": "1.0.4",
"description": "Soroban enabled Stellar Wallet",
"version": "1.0.5",
"description": "Soroban enabled Stellar Wallet (XLM)",
"proposedName": "Stellar",
"repository": {
"type": "git",
"url": "https://github.com/paulfears/StellarSnap.git"
},
"source": {
"shasum": "T5VbYPw/j/r1shsNJhw2LOv1mDCwHBDOzqkfWX9nA9A=",
"shasum": "YMo1TrKWWg1TY8H7vjE45FkcKQYpujDkbykmHyhfhsE=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
10 changes: 6 additions & 4 deletions snap/federation.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { Account, Address, Keypair } from "stellar-base"
import {Auth} from './Auth'

import Utils from "./Utils";
interface fedResponse{
stellar_address:string | null,
account_id:string | null,
Expand All @@ -16,7 +18,7 @@ interface createFedResponse{
export async function createFederationAccount(account:Keypair, username:string): Promise<createFedResponse>{

const preflightRun = await lookupAddress(account.publicKey());
const preflightRun2 = await lookupFedAccount(username+"*metastellar.io");
const preflightRun2 = (await lookupFedAccount(username+"*metastellar.io")) as fedResponse;

if(preflightRun.error !== "not found"){
return {"error": "address already has an account", 'success':false}
Expand Down Expand Up @@ -68,7 +70,7 @@ export async function createFederationAccount(account:Keypair, username:string):
*/
}

export async function lookupFedAccount(name:string):Promise<fedResponse>{
export async function lookupFedAccount(name:string):Promise<fedResponse | undefined>{
try{
const res = await fetch(`https://stellarid.io/federation/?q=${name}&type=name`, {
method: "GET",
Expand All @@ -85,12 +87,12 @@ export async function lookupFedAccount(name:string):Promise<fedResponse>{
}
const output = await res.json();
console.log(output);
return output;
return output as fedResponse;
}
catch(e){
console.log("there was an error");
console.log(e);
return e;
Utils.throwError(400, String(e));
}
}

Expand Down
2 changes: 1 addition & 1 deletion snap/screens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ export class Screens{
divider(),
text("What is a good name for your wallet?")
])
const walletName = await Utils.displayPanel(greeting, 'prompt');
const walletName = await Utils.displayPanel(greeting, 'prompt') as string | null;
if(walletName === null){
//if the user presses cancel on the name just keep the default name
return;
Expand Down

0 comments on commit 49d7915

Please sign in to comment.