Skip to content

Instantly share code, notes, and snippets.

@bergeron
bergeron / multicall.js
Last active January 4, 2024 04:55
Multicall with fallback
// Given an array of contract calls, executes them via a single multicall RPC
// request if the chain supports it. And multiple parallel RPC calls otherwise.
const { Contract } = require('@ethersproject/contracts');
const { StaticJsonRpcProvider } = require('@ethersproject/providers');
const provider = new StaticJsonRpcProvider('https://sepolia.infura.io/v3/<OMITTED>')
const multicallContract = new Contract('0xcA11bde05977b3631167028862bE2a173976CA11', [
{
"name": "aggregate3", "type": "function", "stateMutability": "payable",
@bergeron
bergeron / tokenStandardAndDetails.sol
Created October 4, 2023 15:21
Smart contract to get token standard and details
pragma solidity ^0.8.18;
import "@openzeppelin/contracts/utils/introspection/ERC165Checker.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol";
import "@openzeppelin/contracts/token/ERC1155/extensions/IERC1155MetadataURI.sol";
import "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
contract GetTokenStandardAndDetails {
bytes4 private constant ERC721_INTERFACE = 0x80ac58cd;
bytes4 private constant ERC1155_INTERFACE = 0xd9b67a26;
@bergeron
bergeron / WatcherTest.cs
Created October 13, 2020 21:31
Repro of k8s watcher on AKS staying open and missing events (https://github.com/Azure/AKS/issues/1755)
using k8s;
using k8s.Models;
using Microsoft.Rest;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Threading;
using System.Threading.Tasks;
@bergeron
bergeron / k8s.io.api.admission.v1.swagger.json
Created September 30, 2020 22:18
Swagger 2.0 spec for k8s.io/api/admission/v1
{
"swagger": "2.0",
"info": {
"title": "k8s.io/api/admission/v1",
"version": "1.0"
},
"paths": {},
"definitions": {
"runtime.RawExtension": {
"description": "RawExtension is used to hold extensions in external versions.\n\nTo use this, make a field which has RawExtension as its type in your external, versioned struct, and Object in your internal struct. You also need to register your various plugin types.\n\n// Internal package: type MyAPIObject struct {\n\truntime.TypeMeta `json:\",inline\"`\n\tMyPlugin runtime.Object `json:\"myPlugin\"`\n} type PluginA struct {\n\tAOption string `json:\"aOption\"`\n}\n\n// External package: type MyAPIObject struct {\n\truntime.TypeMeta `json:\",inline\"`\n\tMyPlugin runtime.RawExtension `json:\"myPlugin\"`\n} type PluginA struct {\n\tAOption string `json:\"aOption\"`\n}\n\n// On the wire, the JSON will look something like this: {\n\t\"kind\":\"MyAPIObject\",\n\t\"apiVersion\":\"v1\",\n\t\"myPlugin\": {\n\t\t\"kind\":\"PluginA\",\n\t\t\"aOption\":\"foo
@bergeron
bergeron / k8s.io.api.admission.v1beta1.swagger.json
Created September 30, 2020 22:17
Swagger 2.0 spec for k8s.io/api/admission/v1beta1
{
"swagger": "2.0",
"info": {
"title": "k8s.io/api/admission/v1beta1",
"version": "1.0"
},
"paths": {},
"definitions": {
"runtime.RawExtension": {
"description": "RawExtension is used to hold extensions in external versions.\n\nTo use this, make a field which has RawExtension as its type in your external, versioned struct, and Object in your internal struct. You also need to register your various plugin types.\n\n// Internal package: type MyAPIObject struct {\n\truntime.TypeMeta `json:\",inline\"`\n\tMyPlugin runtime.Object `json:\"myPlugin\"`\n} type PluginA struct {\n\tAOption string `json:\"aOption\"`\n}\n\n// External package: type MyAPIObject struct {\n\truntime.TypeMeta `json:\",inline\"`\n\tMyPlugin runtime.RawExtension `json:\"myPlugin\"`\n} type PluginA struct {\n\tAOption string `json:\"aOption\"`\n}\n\n// On the wire, the JSON will look something like this: {\n\t\"kind\":\"MyAPIObject\",\n\t\"apiVersion\":\"v1\",\n\t\"myPlugin\": {\n\t\t\"kind\":\"PluginA\",\n\t\t\"aOption\":