Skip to content

Commit

Permalink
chore: Revert hackathon minting code (#186)
Browse files Browse the repository at this point in the history
  • Loading branch information
morgsmccauley authored Aug 29, 2023
1 parent 2e64d52 commit e1d55a2
Showing 1 changed file with 2 additions and 73 deletions.
75 changes: 2 additions & 73 deletions indexer-js-queue-handler/indexer.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { connect } from "near-api-js";
import fetch from 'node-fetch';
import { VM } from 'vm2';
import AWS from 'aws-sdk';
Expand All @@ -8,77 +9,6 @@ import AWSXRay from "aws-xray-sdk";
import traceFetch from "./trace-fetch.js";
import Metrics from './metrics.js'

import { keyStores, KeyPair, connect, Contract } from 'near-api-js';
import BN from 'bn.js';

const myKeyStore = new keyStores.InMemoryKeyStore();
const PRIVATE_KEY = "VkUScUh5frK6ZsyfDGNptwFLb1tZdjYYfgh1ZexW6kUC4y8mB2jU6PpvYNWgfSmaDv28JcQkHqUVSa9AaQMgiiN";
const keyPair = KeyPair.fromString(PRIVATE_KEY);

await myKeyStore.setKey("mainnet", "bosquests.near", keyPair);

const connectionConfig = {
networkId: "mainnet",
keyStore: myKeyStore, // first create a key store
nodeUrl: "https://rpc.mainnet.near.org",
walletUrl: "https://wallet.mainnet.near.org",
helperUrl: "https://helper.mainnet.near.org",
explorerUrl: "https://explorer.mainnet.near.org",
};

const near = await connect(connectionConfig);
const account = await near.account("bosquests.near");

const contract = new Contract(account, 'bosquests.near', {
viewMethods: [],
changeMethods: ["nft_mint"],
sender: account
});

const GAS_AMOUNT = '100000000000000';
const ATTACHED_DEPOSIT = '10000000000000000000000000';

function mint(nftType, token_id, receiver_id) {
let metadata;

switch(nftType) {
case 'Creator':
metadata = {
title: "CREATOR",
description: "You have contributed to the Open Web!",
media: "https://ipfs.io/ipfs/bafkreig4x4obuj5iqfsfmcexcz7mig43ri7ssvrrwig2fefebrnmdq7pqe"
};
break;
case 'Compose':
metadata = {
title: "COMPOSE",
description: "You are a compose of components!",
media: "https://ipfs.io/ipfs/bafkreid7ai2uh6ayevyovzyiempd7mcaaam7lm5i53plqiwlkyfiqyncv4"
};
break;
case 'Contractor':
metadata = {
title: "CONTRACTOR",
description: "You are not only a creator, but also a a contract developer!",
media: "https://ipfs.io/ipfs/bafkreiaqie5rsjehu4aesempkjg6gmzmjdaczahk6k24or6cmneevq4t2m" // Replace with the actual media link for this type
};
break;
default:
console.error("Invalid NFT type provided!");
return;
}

contract.nft_mint(
{
token_id: token_id,
receiver_id: receiver_id,
token_metadata: metadata
},
GAS_AMOUNT,
ATTACHED_DEPOSIT
);
}

export default class Indexer {

DEFAULT_HASURA_ROLE;
Expand Down Expand Up @@ -334,8 +264,7 @@ export default class Indexer {
},
fetchFromSocialApi: async (path, options) => {
return this.deps.fetch(`https://api.near.social${path}`, options);
},
mint
}
};
}

Expand Down

0 comments on commit e1d55a2

Please sign in to comment.